File tree Expand file tree Collapse file tree
references/hello-world/src/trigger Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments