How durable execution works
Two primitives create durability boundaries in a workflow:Workflow.step()— executes an effect and caches the result in Durable Object storage. On resume, the cached result is replayed without re-executing the effect.Workflow.sleep()— persists the wake-up time and pauses the workflow. A Cloudflare Durable Object alarm fires at the scheduled time to resume execution.
Execution modes
When the executor runs a workflow, it operates in one of three modes:| Mode | When used | Behavior |
|---|---|---|
fresh | First execution | No cached data — execute all steps |
resume | After a sleep or retry delay | Replay cached step results, continue from the pause point |
recover | After an infrastructure failure | Same as resume, triggered by the recovery system when a stale Running workflow is detected |
Workflow state machine
Every workflow instance transitions through a defined set of states:| State | Valid next states |
|---|---|
Pending | Running, Queued |
Queued | Running, Cancelled |
Running | Completed, Paused, Failed, Cancelled |
Paused | Running, Cancelled |
Completed | — (terminal) |
Failed | — (terminal) |
Cancelled | — (terminal) |
Paused workflows resume when their scheduled alarm fires. Running workflows that appear stale after a server restart are detected by the recovery system and re-executed in recover mode.
What to read next
Steps
Cache results and build the core logic of your workflow
Sleep
Pause for seconds, hours, or days across restarts
Retry and timeouts
Configure backoff strategies and per-step deadlines
Cloudflare setup
Wire up Durable Objects bindings and wrangler config
Client
Start, monitor, and cancel workflow instances
