Skip to main content
By default, workflows time out after 5 minutes. Steps let you break a workflow into a series of checkpoints that are persisted individually. If a workflow is interrupted, it resumes from the last completed step.

Basic steps

The step function takes a unique name and a handler. The return value is persisted and reused if the step has already completed:
Step names should be unique. If the same name runs twice, the second call returns the first one’s cached result instead of running. Steps can be nested. A parent step completes when all its sub-steps complete.

Retries

Steps retry automatically on failure. Control the number of attempts with maxAttempts (defaults to 5):
If a step exhausts all retries, it throws an error. This fails the entire workflow unless you catch it:

Sleep

Pause the workflow for a duration (in milliseconds) or until a specific time:
The workflow is suspended during sleep, and no further compute is used.

Progress

Use .progress() to record a checkpoint without running any work. This is useful for observability when you want to mark milestones in a long handler:

Listen

Use .listen() to suspend the workflow and set its status to "listening". The workflow then waits to be resumed by an external event. You can specify this event by passing its name in as an argument:

Fail and abort

Use .fail() or .abort() to stop execution explicitly:

Child workflows

You can start another workflow and wait for it to complete:
Or wait for an already-running workflow:

Parallel processing

map

Process an array of items in parallel and collect results:

forEach

Process items in parallel without collecting results:

batch

Process items in sequential batches:
Last modified on April 27, 2026