← Back
Cloudflare
Cloudflare Workflows adds step context access in production and local development

Cloudflare has expanded the capabilities of Workflows by introducing step context support that allows developers to inspect which retry attempt is currently executing. This is particularly useful for implementing sophisticated error handling and monitoring strategies.

Key Addition

The new ctx.attempt parameter provides access to the current retry attempt number (1-indexed) when executing steps via step.do():

await step.do("my-step", async (ctx) => {
  console.log(`Attempt ${ctx.attempt}`);
});

Use Cases

Developers can leverage step context for:

  • Enhanced Logging & Observability: Track which retry attempt is executing to identify patterns in transient failures
  • Progressive Backoff: Implement custom backoff strategies that increase delays based on attempt number
  • Conditional Logic: Execute different code paths depending on the retry attempt count

Availability

The feature is available in both production environments and local development, making it easier to test retry behavior before deploying to production. For detailed information on retry behavior and configuration, refer to the Workflows documentation on sleeping and retrying.