Combines hook() + waitFor() into a single call: spawns a hook
function on a target workflow and suspends the current workflow until
the hook signals completion. This is the recommended pattern for
request/response communication between workflow threads.
Signal Injection
A signalId is automatically generated (or use the one you provide)
and injected as the last argument to the hooked function as
{ signal: string, $durable: true }. The hook function must call
Durable.workflow.signal(signalInfo.signal, result) to deliver
its response back to the waiting workflow.
Difference from execChild
execChild spawns a new workflow job with its own lifecycle.
execHook runs within an existing workflow's job, in an
isolated dimensional thread. This is lighter-weight and shares
the parent job's data namespace.
Examples
import { Durable } from'@hotmeshio/hotmesh';
// Orchestrator: spawn a hook and await its result exportasyncfunctionreviewWorkflow(docId: string): Promise<string> { constverdict = awaitDurable.workflow.execHook<{ approved: boolean }>({ taskQueue:'reviewers', workflowName:'reviewDocument', args: [docId], });
Combines
hook()+waitFor()into a single call: spawns a hook function on a target workflow and suspends the current workflow until the hook signals completion. This is the recommended pattern for request/response communication between workflow threads.Signal Injection
A
signalIdis automatically generated (or use the one you provide) and injected as the last argument to the hooked function as{ signal: string, $durable: true }. The hook function must callDurable.workflow.signal(signalInfo.signal, result)to deliver its response back to the waiting workflow.Difference from
execChildexecChildspawns a new workflow job with its own lifecycle.execHookruns within an existing workflow's job, in an isolated dimensional thread. This is lighter-weight and shares the parent job's data namespace.Examples