Skip to content

Commit 000eae4

Browse files
committed
test(references): add dynamic-import repro tasks to hello-world
1 parent adf0ab7 commit 000eae4

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { task } from "@trigger.dev/sdk";
2+
3+
// Defined in a module that's loaded via `await import(...)` from the parent
4+
// task's run() function. Pre-fix: the task() call below fires while
5+
// `_currentFileContext` is unset, so the registration is silently dropped.
6+
// Post-fix: registered with sentinel file metadata + console.warn fires once.
7+
export const lazyChildTask = task({
8+
id: "lazy-child-task",
9+
run: async (payload: { value: string }) => {
10+
return { received: payload.value };
11+
},
12+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { logger, task } from "@trigger.dev/sdk";
2+
3+
// Triggers the dynamic-import silent-drop path. The child task's `task()`
4+
// definition lives in a module loaded via `await import(...)` inside this
5+
// parent's run() — so its registration would land outside the worker's
6+
// cold-load context window.
7+
export const dynamicImportReproParent = task({
8+
id: "dynamic-import-repro-parent",
9+
run: async () => {
10+
logger.info("parent: about to dynamically import child task module");
11+
const { lazyChildTask } = await import("./dynamicImportReproChild.js");
12+
logger.info("parent: import complete, triggering child");
13+
const handle = await lazyChildTask.trigger({ value: "hello from parent" });
14+
logger.info("parent: child triggered", { childRunId: handle.id });
15+
return { childRunId: handle.id };
16+
},
17+
});

0 commit comments

Comments
 (0)