Skip to content

BackoffOptions

Defined in: src/pattern/BackoffSupervisor.ts:110

T

readonly optional childName?: string

Defined in: src/pattern/BackoffSupervisor.ts:116

Name suffix for the child. The actual child name is ${childName}-${incarnation} so successive incarnations don’t collide on names while the previous instance is still tearing down.


readonly childProps: Props<T>

Defined in: src/pattern/BackoffSupervisor.ts:112

How to construct the child.


readonly optional clock?: () => number

Defined in: src/pattern/BackoffSupervisor.ts:169

Override Date.now/Math.random for deterministic tests.

number


readonly optional drainGraceMs?: number

Defined in: src/pattern/BackoffSupervisor.ts:146

Grace period after a respawn before stashed messages are forwarded to the new child. This protects buffered messages against children that crash in preStart — if the child dies during the grace window, the stash is preserved for the next incarnation.

Default: min(50ms, minBackoff). Set 0 to disable (drain immediately on spawn — the v0 behaviour).


readonly optional forward?: ForwardStrategy

Defined in: src/pattern/BackoffSupervisor.ts:128

What to do with messages while the child is dead. Default 'stash'.


readonly optional forwardDuringGrace?: boolean

Defined in: src/pattern/BackoffSupervisor.ts:167

What to do with messages that arrive during the grace window (after a respawn, before the child has proven it survives drainGraceMs). Two modes (#67):

  • true (default) — v1 behaviour. New messages forward immediately to the about-to-be-confirmed child; if that child dies in preStart, those forwarded messages dead-letter. Lowest latency on the happy path, accepts dead-letters during a preStart-crash cascade.
  • false — strict mode. New messages stash until the grace expires, then drain alongside the carry-over stash from the previous incarnation. Costs up to drainGraceMs of latency on the first messages after a respawn but guarantees nothing dead-letters when the child keeps crashing in preStart. Opt-in to fix the dead-letter cascade described in #67.

Has no effect when drainGraceMs === 0 — without a grace there is no “uncertain” window for the gate to apply to.


readonly maxBackoff: number

Defined in: src/pattern/BackoffSupervisor.ts:120

Ceiling for the backoff delay, in ms. Must be >= minBackoff.


readonly optional maxStashSize?: number

Defined in: src/pattern/BackoffSupervisor.ts:136

Stash buffer size (only when forward === 'stash'). Default 1000.


readonly minBackoff: number

Defined in: src/pattern/BackoffSupervisor.ts:118

Floor for the backoff delay, in ms. Must be > 0.


readonly optional policy?: BackoffPolicy

Defined in: src/pattern/BackoffSupervisor.ts:124

Custom policy — overrides the default exponential backoff.


readonly optional randomFactor?: number

Defined in: src/pattern/BackoffSupervisor.ts:122

Jitter fraction in [0, 1]. Default 0.2.


readonly optional resetCounter?: ResetCounter

Defined in: src/pattern/BackoffSupervisor.ts:126

Counter-reset rule. Default 'after-min-stable'.


readonly optional triggerOn?: TerminationTrigger

Defined in: src/pattern/BackoffSupervisor.ts:134

Which terminations should trigger a respawn. Default 'any' (current v1 behaviour: respawn on crash AND on clean stop). See TerminationTrigger for the three modes.