Shaf Lab

Durable workflows

Multi-step jobs that can wait, retry, and resume after a failure.

A durable workflow is a multi-step job that can wait, retry, and resume after a failure or a long pause. It is the pattern behind systems like Cloudflare Workflows or Temporal: each step is recorded, so a crash does not restart the whole process from scratch. You use it when a job is longer than a single request and must not be forgotten.

The shape is a sequence or a graph of steps: charge the card, send the mail, wait for a webhook, then mark the order complete. Sleeps can be hours or days. If a step fails, the runtime retries it with a policy you set, and the already finished steps stay done. That is the difference from a cron script that repeats the entire pipeline.

Keep steps idempotent. A retry should not double-charge or send five copies of the same message. Store the business identifiers you need to make that safe. Prefer a workflow when the business process itself is long-running; prefer a queue when you just need to absorb a burst of similar messages.

Start with one workflow you can draw on a single page. If you cannot name the steps and the failure policy, it is too early to introduce a new runtime.