Skip to content

RetryOptions

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:65

Retry configuration of the behavior — re-runs all downstream pipeline work on a handled failure.

optional backoff?: RetryBackoff

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:61

Delay strategy between attempts. Defaults to no delay.

RetryPolicyOptions.backoff


maxAttempts: number

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:58

Maximum number of retry attempts after the initial call (e.g. 3 allows the original execution plus up to three retries), matching Cockatiel’s retry(..., { maxAttempts }) semantics.

RetryPolicyOptions.maxAttempts


optional replaySafe?: boolean

Defined in: packages/pipeline-resilience/src/interfaces/resilience-options.interface.ts:90

Explicit acknowledgement that replaying the handler/downstream behaviors is safe. Required for command and event retries because those request kinds commonly perform side effects.

Queries do not require this acknowledgement.

Set this only when the operation is genuinely replay-safe — for example the side effect is protected by a downstream idempotency key, transaction, or otherwise repeatable contract. @cqrs-ddd/pipeline-idempotency does not make arbitrary external effects exactly-once by itself.

Replay-safe command retry

@pipeline.wrap({ kind: 'command' }, [ResilienceBehavior, {
retry: {
maxAttempts: 2,
replaySafe: true,
backoff: { type: 'exponential', maxDelay: 1_000 },
},
handle: (error) => error instanceof TransientGatewayError,
}])