Skip to main content

suspend()

Pauses workflow execution at the current step until explicitly resumed. The workflow state is persisted and can be continued later.

Usage ExampleDirect link to Usage Example

const approvalStep = new LegacyStep({
id: "needsApproval",
execute: async ({ context, suspend }) => {
if (context.steps.amount > 1000) {
await suspend();
}
return { approved: true };
},
});

ParametersDirect link to Parameters

metadata?:

Record<string, any>
Optional data to store with the suspended state

ReturnsDirect link to Returns

Promise<void>:

Promise
Resolves when the workflow is successfully suspended

Additional ExamplesDirect link to Additional Examples

Suspend with metadata:

const reviewStep = new LegacyStep({
id: "review",
execute: async ({ context, suspend }) => {
await suspend({
reason: "Needs manager approval",
requestedBy: context.user,
});
return { reviewed: true };
},
});

On this page