• Spawns a child workflow and awaits its result. The child runs as an independent job with its own lifecycle, retry policy, and dimensional isolation. If the child fails, the error is propagated to the parent as a typed error (DurableFatalError, DurableMaxedError, DurableTimeoutError, or DurableRetryError).

    On replay, the stored child result is returned immediately without re-spawning the child workflow.

    If options.workflowId is provided, it is used directly. Otherwise, the child ID is generated from the entity/workflow name, a GUID, the parent's dimensional coordinates, and the execution index — ensuring uniqueness across parallel and re-entrant executions.

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

    // Spawn a child workflow and await its result
    export async function parentWorkflow(orderId: string): Promise<string> {
    const result = await Durable.workflow.execChild<{ status: string }>({
    taskQueue: 'payments',
    workflowName: 'processPayment',
    args: [orderId, 99.99],
    config: {
    maximumAttempts: 3,
    backoffCoefficient: 2,
    },
    });
    return result.status;
    }
    // Fan-out: spawn multiple children in parallel
    export async function batchWorkflow(items: string[]): Promise<string[]> {
    const results = await Promise.all(
    items.map((item) =>
    Durable.workflow.execChild<string>({
    taskQueue: 'processors',
    workflowName: 'processItem',
    args: [item],
    }),
    ),
    );
    return results;
    }
    // Entity-based child (uses entity name as task queue)
    const user = await Durable.workflow.execChild<UserRecord>({
    entity: 'user',
    args: [{ name: 'Alice', email: 'alice@example.com' }],
    workflowId: 'user-alice', // deterministic ID
    expire: 3600, // 1 hour TTL
    });

    Type Parameters

    • T

      The return type of the child workflow.

    Parameters

    Returns Promise<T>

    The child workflow's return value.