Workflow steps now expose retry attempt number via step context
Key Points
- ctx.attempt exposed in step context
- attempt number is 1-indexed
- use for logging, backoff, conditional logic
Summary
Cloudflare Workflows now exposes the current retry attempt number on each step's context for calls to step.do(). Inside your step handler use ctx.attempt to get the attempt number (1-indexed).
Key Points
- Access the attempt number via
ctx.attemptinawait step.do("my-step", async (ctx) => { ... }). ctx.attemptis 1 on the first try, 2 on the first retry, etc.- Use cases: improved logging and observability, progressive backoff strategies, or conditional logic based on attempt count.
- Practical: ensure handlers are idempotent and review the Workflows "Sleeping and Retrying" docs for retry semantics and limits.