Spawns a hook execution against an existing workflow job. The hook runs
in an isolated dimensional thread within the target job's namespace,
allowing it to read/write the same job state without interfering with
the main workflow thread.
This is the low-level primitive behind execHook(). Use hook()
directly when you need fire-and-forget hook execution or when you
manage signal coordination yourself.
Target Resolution
If taskQueue and workflowName (or entity) are provided, the
hook targets that specific workflow type.
If neither is provided, the hook targets the current workflow.
However, targeting the same topic as the current workflow is
rejected to prevent infinite loops.
Idempotency
The isSideEffectAllowed guard ensures hooks fire exactly once —
on replay, the hook is not re-spawned.
Examples
import { Durable } from'@hotmeshio/hotmesh';
// Fire-and-forget: spawn a hook without waiting for its result exportasyncfunctionnotifyWorkflow(userId: string): Promise<void> { awaitDurable.workflow.hook({ taskQueue:'notifications', workflowName:'sendNotification', args: [userId, 'Your order has shipped'], }); // Continues immediately, does not wait for the hook }
// Manual signal coordination (equivalent to execHook) exportasyncfunctionmanualHookPattern(itemId: string): Promise<string> { constsignalId = `process-${itemId}`;
Spawns a hook execution against an existing workflow job. The hook runs in an isolated dimensional thread within the target job's namespace, allowing it to read/write the same job state without interfering with the main workflow thread.
This is the low-level primitive behind
execHook(). Usehook()directly when you need fire-and-forget hook execution or when you manage signal coordination yourself.Target Resolution
taskQueueandworkflowName(orentity) are provided, the hook targets that specific workflow type.Idempotency
The
isSideEffectAllowedguard ensures hooks fire exactly once — on replay, the hook is not re-spawned.Examples