Cloudflare Workflows Adds Saga-Style Rollbacks for Durable Multi-Step Apps

Cloudflare · 25 Jun 2026 · 2 min read

#cloudflare

Cloudflare Workflows, the platform's durable execution engine for building multi-step applications, has introduced native support for saga-style rollbacks. This feature allows developers to specify compensating actions for each step, ensuring that when a workflow step fails, the system automatically executes the corresponding rollback logic to revert any partial changes. The update eliminates the need to manually manage compensation logic or external transaction coordination.

  • New .onRollback() method on each step.do() call: define a rollback handler that runs when a step fails or the workflow is manually terminated. For example:
    await step.do(
      'charge-customer',
      async () => await charge(params),
      async () => await refund(params)
    );
    
  • Automatic rollback execution: If any step throws an error, Workflows runs all .onRollback() handlers for previously completed steps in reverse order (LIFO), applying the compensating actions.
  • Built-in failure and timeout handling: Workflows already triggers .onRollback on step timeouts or other failure conditions, integrating with existing Workers and Workflows APIs.
  • No additional infrastructure: Rollback logic runs within the same durable execution environment, using the same env bindings and state management as forward steps.
  • Manual rollback via API: Developers can also trigger rollbacks externally using the rollback API on a workflow instance, which replays the compensation sequence from the last successful step.

For developers building transactional multi-step workflows (e.g., order processing, payment pipelines, resource provisioning), this feature drastically reduces the complexity of handling partial failures. Instead of crafting bespoke error-recovery code, they can now declaratively attach rollback handlers directly to each step. Combined with Workflows' existing retry and state persistence, saga rollbacks make it production-ready for mission-critical, long-running processes. This aligns Cloudflare Workflows with the saga pattern popularized by distributed systems, but without requiring a separate coordinator or external queue.

Source: https://blog.cloudflare.com/rollbacks-for-workflows/

Related

auto-curated · source linked above ← all news