Steps
context.cancel
All of the methods covered so far are used to define workflow steps.
context.cancel is different — it allows you to explicitly cancel the current workflow run.
export const { POST } = serve<{ topic: string }>(async (context) => { const payload = context.requestPayload const result = await context.run("check if canceled", () => { ... }); if (result.cancel) { await context.cancel() // cancel the workflow run }})When a workflow run is canceled:
- It is labeled as canceled (not failed).
- The configured
failureFunctionis not triggered. - No entries are sent to the dead-letter queue (DLQ).