Skip to main content

API Reference: Execution Options (ExecutionOptions)

The ExecutionOptions object configures runtime execution behavior across flow.run(), step.run(), and resumeWorkflow(). It governs cancellation signals, deadlines, dependency injection, durable persistence, multi-tenant namespaces, schema migrations, execution hooks, and idempotency deduplication.

Table of Contents


The ExecutionOptions Interface


Option Details

pojo and mode

Controls output normalization for the workflow result:
  • pojo: true (default in v1.0): Automatically strips internal proxy wrappers and execution internals, returning clean plain objects. The runtime output path always applies toPOJO normalization.
  • mode: 'pojo' | 'wrapped': Compatibility configuration. Note that reserved context history accessors remain getter functions, and native types like BigInt are not automatically JSON-serializable.

signal

An AbortSignal instance used for cooperative cancellation.
  • Propagation: Passed to every step action via param.signal (native AbortSignal) and param.$signal() (callable compatibility accessor).
  • In-Flight Cancellation: When aborted, pending retry backoff delays and parallel sibling branches are aborted. Note that asynchronous work inside step actions must cooperate with param.signal (e.g. passing it to fetch({ signal })).
  • Exception: Throws CancellationException with the abort reason.

timeout and timeoutMs

Workflow-level SLA deadline in milliseconds.
  • If the total execution time of the entire workflow exceeds this limit, execution is immediately aborted.
  • Throws FlowTimeoutException containing timeoutMs, stackId, and completedSteps.

services and dependencies

Dependency injection container for injecting repositories, external clients, database connections, and configurations into steps without coupling step implementations to global singletons.
  • Accessible inside step actions via param.$services or step.requireDependency().
  • Both services and dependencies are accepted as synonyms.

durable

When set to true, enables durable workflow state management:
  • When a workflow encounters waitForEvent() or wait(), Siglo suspends the workflow, serializes the current execution context into a checkpoint, persists it to the configured StorageAdapter, and resolves with an execution descriptor containing { status: 'waiting', stackId, waitKey }.
  • Allows workflows to pause for hours, days, or months and resume safely upon external event delivery via resumeWorkflow().

workflowVersion

Declares the schema version of the workflow definition (e.g. 'v1', 'v2').
  • Used during durable workflow resumption to detect code changes between when the checkpoint was created and when it was resumed.
  • When resuming via resumeWorkflow(targetFlow, key, payload, options), the target version is selected from options.targetVersion, falling back to targetFlow.workflowVersion, then the checkpoint’s recorded version.
  • If the checkpoint’s version differs from the target version and no matching migration is provided in migrations, WorkflowVersionMismatchException is thrown.

migrations

A migration map or migration function for upgrading suspended checkpoint state when workflow definitions evolve. Transition keys use 'fromVersion->toVersion' format and receive (fromVersion, toVersion, state) => newState:

namespace

A string partition key used for multi-tenant metadata scoping and storage key partitioning.
  • Partitions checkpoint keys, cached step outputs, and wait records to prevent key collisions across tenants.
  • restoreCheckpoint checks an explicitly supplied expected namespace when both values exist.
  • Security Note: Namespace scoping is logical key partitioning, not an enforced authenticated tenant boundary. Application-level tenant authentication and explicit validation are still required.

idempotencyKey

A string or generator function providing workflow-level deduplication.
  • Prevents concurrent duplicate runs (e.g. double-submitted webhooks or duplicate HTTP requests).
  • If an execution with this key is already running, throws IdempotencyConflictException.
  • If already completed within idempotencyTtlMs, returns the cached result.

idempotencyStore

Custom adapter implementing the IdempotencyStore interface (e.g. PostgresIdempotencyStore, RedisIdempotencyStore, or InMemoryIdempotencyStore).

idempotencyTtlMs

Retention window for idempotency records in milliseconds:
  • Redis / PostgreSQL stores: Default to 86400000 (24 hours).
  • In-Memory store: No expiration by default (expiresAt remains undefined unless ttlMs is explicitly supplied; TTL starts at claim time).
  • Queue adapters (Kafka, BullMQ, SQS): Pass undefined through to the store when idempotencyTtlMs is omitted.

stepExecutionHook

Intercepts step execution boundaries within Node’s AsyncLocalStorage context. Enables custom per-run logging, timing metrics, and distributed APM spans without registering global plugins.

networkPolicy

Supplies dynamic network egress guardrails for this execution run, overriding or narrowing the workflow-level policy.

workflowId

Human-readable workflow identifier attached to telemetry, logs, and checkpoints.

stackId

Explicit caller-provided execution stack ID. If omitted, Siglo automatically generates a unique UUID.

Comprehensive Production Example