Sends a signal payload to a paused workflow thread that is awaiting this
signalId via waitFor(). Signals are the primary mechanism for
inter-workflow communication and for delivering results from hook
functions back to the orchestrating workflow.
signal is the send side of the coordination pair. The receive
side is waitFor(). A signal can be sent from:
Another workflow function
A hook function (most common pattern with execHook)
An external client via Durable.Client.workflow.signal()
Signals fire exactly once per workflow execution — the isSideEffectAllowed
guard ensures they are not re-sent on replay.
Examples
import { Durable } from'@hotmeshio/hotmesh';
// Hook function that signals completion back to the parent workflow exportasyncfunctionprocessOrder( orderId: string, signalInfo?: { signal: string; $durable: boolean }, ): Promise<{ total: number }> { const { calculateTotal } = Durable.workflow.proxyActivities<typeofactivities>(); consttotal = awaitcalculateTotal(orderId);
// Signal the waiting workflow with the result if (signalInfo?.signal) { awaitDurable.workflow.signal(signalInfo.signal, { total }); } return { total }; }
// Cross-workflow coordination: workflow A signals workflow B exportasyncfunctioncoordinatorWorkflow(): Promise<void> { const { prepareData } = Durable.workflow.proxyActivities<typeofactivities>(); constdata = awaitprepareData();
// Signal another workflow that is paused on waitFor('data-ready') awaitDurable.workflow.signal('data-ready', { payload:data }); }
// External signal from an API handler (outside a workflow) constclient = newDurable.Client({ connection }); awaitclient.workflow.signal('approval-signal', { approved:true });
Parameters
signalId: string
Unique signal identifier that matches a waitFor() call.
Sends a signal payload to a paused workflow thread that is awaiting this
signalIdviawaitFor(). Signals are the primary mechanism for inter-workflow communication and for delivering results from hook functions back to the orchestrating workflow.signalis the send side of the coordination pair. The receive side iswaitFor(). A signal can be sent from:execHook)Durable.Client.workflow.signal()Signals fire exactly once per workflow execution — the
isSideEffectAllowedguard ensures they are not re-sent on replay.Examples