• 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.

    import { Durable } from '@hotmeshio/hotmesh';

    // Hook function that signals completion back to the parent workflow
    export async function processOrder(
    orderId: string,
    signalInfo?: { signal: string; $durable: boolean },
    ): Promise<{ total: number }> {
    const { calculateTotal } = Durable.workflow.proxyActivities<typeof activities>();
    const total = await calculateTotal(orderId);

    // Signal the waiting workflow with the result
    if (signalInfo?.signal) {
    await Durable.workflow.signal(signalInfo.signal, { total });
    }
    return { total };
    }
    // Cross-workflow coordination: workflow A signals workflow B
    export async function coordinatorWorkflow(): Promise<void> {
    const { prepareData } = Durable.workflow.proxyActivities<typeof activities>();
    const data = await prepareData();

    // Signal another workflow that is paused on waitFor('data-ready')
    await Durable.workflow.signal('data-ready', { payload: data });
    }
    // External signal from an API handler (outside a workflow)
    const client = new Durable.Client({ connection });
    await client.workflow.signal('approval-signal', { approved: true });

    Parameters

    • signalId: string

      Unique signal identifier that matches a waitFor() call.

    • data: Record<any, any>

      The payload to deliver to the waiting workflow.

    Returns Promise<string>

    The resulting hook/stream ID.