Skip to main content
Mastra v1 is coming in January 2026. Get ahead by starting new projects with the beta or upgrade your existing project today.

Run.cancel()

The .cancel() method cancels a workflow run, stopping execution and cleaning up resources.

Usage exampleDirect link to Usage example

const run = await workflow.createRunAsync();

await run.cancel();

ParametersDirect link to Parameters

No parameters:

void
This method takes no parameters

ReturnsDirect link to Returns

result:

Promise<void>
A promise that resolves when the workflow run has been cancelled

Extended usage exampleDirect link to Extended usage example

const run = await workflow.createRunAsync();

try {
const result = await run.start({ inputData: { value: "initial data" } });
} catch (error) {
await run.cancel();
}

On this page