Returns the current workflow's execution context, providing access to
the workflow ID, replay state, dimensional coordinates, connection
info, and other runtime metadata.
The context is populated by the worker's wrapWorkflowFunction and
stored in AsyncLocalStorage, making it available to any code running
within the workflow function's call stack.
Examples
import { Durable } from'@hotmeshio/hotmesh';
// Access the workflow ID and namespace exportasyncfunctioncontextAwareWorkflow(): Promise<string> { constctx = Durable.workflow.getContext(); console.log(`Running workflow ${ctx.workflowId} in ${ctx.namespace}`); returnctx.workflowId; }
// Check if the current execution is a replay exportasyncfunctionreplayAwareWorkflow(): Promise<void> { const { counter, workflowDimension } = Durable.workflow.getContext();
// Use context for logging/debugging console.log(`Execution counter: ${counter}, dimension: ${workflowDimension}`); }
// Pass context info to child workflows exportasyncfunctionparentWorkflow(): Promise<void> { const { workflowId } = Durable.workflow.getContext();
awaitDurable.workflow.execChild({ taskQueue:'children', workflowName:'childWorkflow', args: [workflowId], // pass parent ID to child }); }
Returns the current workflow's execution context, providing access to the workflow ID, replay state, dimensional coordinates, connection info, and other runtime metadata.
The context is populated by the worker's
wrapWorkflowFunctionand stored inAsyncLocalStorage, making it available to any code running within the workflow function's call stack.Examples