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 Example

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

Parameters

metadata?:

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

Returns

Promise<void>:

Promise
Resolves when the workflow is successfully suspended

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