Skip to main content
Distributed workflows frequently require undoing partial side effects when a downstream step fails (the Saga Pattern). Siglo provides first-class support for forward execution with automatic backward compensation.

1. Core Saga Pattern & Automatic LIFO Rollback

Compensations execute in exact reverse order (LIFO) of step completion. Only steps that completed successfully prior to the point of failure are compensated.

2. Compensation Registration Patterns

Siglo supports both inline closures and decoupled named compensation handlers.

A. Inline Closures (In-Memory Sagas)

Suitable for single-process, short-lived workflows:

B. Named Handlers & Global Registry (Durable & Multi-Process Sagas)

When workflows are persisted to storage (PostgreSQL, Redis) across service restarts or code deployments, JavaScript closures cannot be serialized. Register named handlers at application startup:

3. Compensation Retry Policy

Transient failures during compensation can be retried with fixed delays or custom conditional predicates:

4. Execution Modes: Strict vs. Best-Effort

When rolling back compensations, Siglo supports two execution modes via CompensationRunOptions:

5. Dead Letter Queue (DLQ) & Failure Callbacks

Capture compensation failures that exhaust all retry attempts without losing context:

6. Error Handling & Exceptions


7. Crash Recovery & Abandoned Stack Reconciler

Manual Saga Compensation

Resume or trigger compensations on an existing or interrupted stack:

Background Reconciliation (reconcileAbandonedStacks)

Detect crashed processes or abandoned workflows in storage and roll them back safely: