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.watch()

The .watch() method allows you to monitor the execution of a workflow run, providing real-time updates on the status of steps.

Usage exampleDirect link to Usage example

const run = await workflow.createRunAsync();

run.watch((event) => {
console.log(event?.payload?.currentStep?.id);
});

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

ParametersDirect link to Parameters

callback:

(event: WatchEvent) => void
A callback function that is called whenever a step is completed or the workflow state changes. The event parameter contains: type ('watch'), payload (currentStep and workflowState), and eventTimestamp

type?:

'watch' | 'watch-v2'
= 'watch'
The type of watch events to listen for. 'watch' for step completion events, 'watch-v2' for data stream events

ReturnsDirect link to Returns

unwatch:

() => void
A function that can be called to stop watching the workflow run

Extended usage exampleDirect link to Extended usage example

const run = await workflow.createRunAsync();

run.watch((event) => {
console.log(event?.payload?.currentStep?.id);
}, "watch");

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

On this page