On this page
Sommatic Docs
Open portal

Compensate Saga

Triggers the compensation process for a distributed transaction (Saga).

View as Markdown
Open in
Operations Experimental saga.compensate Version 1.0.0 Execution: sync

Experimental. Meant to trigger the rollback of a saga. In the current runtime it always leaves through error with logger.warn is not a function; even then, the __signal: "COMPENSATE" it would return is not read by the engine, so no undo step runs.

When a failure occurs in a long-running transaction, this operator instructs the engine to "rollback" by executing the registered compensation steps for all previously successful activities in reverse order.

Behavior:

  • Identifies the active Saga Scope.
  • Retrieves the 'undo' operations for completed steps.
  • Executes them stack-wise (LIFO).

Use Cases:

  • Rolling back a payment if inventory reservation fails.
  • Cancelling a hotel booking if the flight is unavailable.

How it works

  1. Merges the input item with the resolved config (config wins).
  2. Uses reason (default Manual Trigger) and saga_id from the config or the input item.
  3. With or without saga_id, calls logger.warn(), which throws; the worker catches it and leaves through error. The steps below are not reached today.
  4. Without saga_id: would leave through error with No Active Saga.
  5. With saga_id: would return { __signal: "COMPENSATE", saga_id, reason, port: "compensated", compensated: true }, which the engine passes on as plain output.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-compensate-order",
  "label": "Compensate order saga",
  "operator_slug": "saga.compensate",
  "operator_version": "1.0.0",
  "config": {
    "saga_id": "{{ $json.saga_id }}",
    "reason": "Payment declined"
  }
}

Configuration

This node has no configuration fields.

Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

saga_id
Not in the config schema (only in the input contract), but read from the node config or, when unset there, from the input item: saga_id, reason.

Output ports

compensated default

Not reached in the current runtime: the logger.warn() call fails first. Shown with the shape the code builds.

Data
{
  "__signal": "COMPENSATE",
  "saga_id": "ce78b34b-0bf5-4372-89b0-ae0eb6adddc1",
  "reason": "Payment declined",
  "port": "compensated",
  "compensated": true
}
error

Every run today. The output is the whole returned object, { port, error }.

Data
{
  "port": "error",
  "error": "logger.warn is not a function"
}

In expressions

What a later node can read from this node's output with $("Compensate Saga").item.json.<path> (write your node's label instead of Compensate Saga). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through compensated, from the output shown in Ports.

ExpressionEditorWorker
$("Compensate Saga").item.json.compensatedboolean= trueTrue if compensation workflow initiated.
$("Compensate Saga").item.json.__signalstringNot suggested by the editor= "COMPENSATE"—
$("Compensate Saga").item.json.saga_idstringNot suggested by the editor= "ce78b34b-0bf5-4372-89b0-ae0eb6adddc1"—
$("Compensate Saga").item.json.reasonstringNot suggested by the editor= "Payment declined"—
$("Compensate Saga").item.json.portstringNot suggested by the editor= "compensated"—

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Errors

Message Port Cause and fix
logger.warn is not a function error The worker calls logger.warn(), which the runtime logger does not provide. It happens on every run; there is no configuration that avoids it.
No Active Saga error Not reached today. It would mean that saga_id is set neither on the node nor in the input item; the fallback to an active saga in the context never finds one.

Input contract

reason string Optional

Reason for compensation trigger.

saga_id string Optional

Specific Saga ID (optional, defaults to context).

Output contract

compensated boolean Optional

True if compensation workflow initiated.

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "saga.compensate",
  "name": "Compensate Saga",
  "category": "ops",
  "version": "1.0.0",
  "description": "Triggers the compensation process for a distributed transaction (Saga).\n\n  When a failure occurs in a long-running transaction, this operator instructs the engine to \"rollback\" by executing the registered compensation steps for all previously successful activities in reverse order.\n\n  **Behavior:**\n  - Identifies the active Saga Scope.\n  - Retrieves the 'undo' operations for completed steps.\n  - Executes them stack-wise (LIFO).\n\n  **Use Cases:**\n  - Rolling back a payment if inventory reservation fails.\n  - Cancelling a hotel booking if the flight is unavailable.",
  "capabilities": [
    "saga",
    "transaction",
    "rollback",
    "ops"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "reason": {
        "type": "string",
        "description": "Reason for compensation trigger."
      },
      "saga_id": {
        "type": "string",
        "description": "Specific Saga ID (optional, defaults to context)."
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "compensated": {
        "type": "boolean",
        "description": "True if compensation workflow initiated."
      }
    }
  },
  "ports": [
    {
      "port_id": "compensated",
      "label": "Compensated",
      "is_default": true,
      "description": "Compensation process started."
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Failed to trigger compensation."
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "saga",
    "rollback",
    "transaction"
  ],
  "is_stateful": true,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

Execution

Execution
sync
Stateful
Yes
Retries (retryOnFail)
No
Capabilities
sagatransactionrollbackops
Tags
sagarollbacktransaction

Notes and limits

  • The worker calls logger.warn(), which the runtime logger does not provide (it offers info, warning, error, log and success). The call throws on every run.
  • Missing for a working compensation: the engine does not read __signal, keeps no saga history and has no step that runs undo logic. Model rollbacks today with flow.try and explicit compensation nodes.
  • Leaving through error does not fail the run: the engine follows the edges wired to error, and if there are none the branch simply ends.
  • The execution settings (retryOnFail, maxTries, waitBetweenTries, continueOnFail, timeout_ms) are accepted, but neither this worker nor the engine applies them.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs