Skip to content
English

RetryOptions

RetryOptions = object

Defined in: src/pattern/retry.ts:1

readonly attempts: number

Defined in: src/pattern/retry.ts:3

Total attempts including the initial call. Must be >= 1.


readonly optional delayMs?: number

Defined in: src/pattern/retry.ts:5

Base delay between retries, in ms.


readonly optional factor?: number

Defined in: src/pattern/retry.ts:7

Exponential-backoff multiplier applied to delayMs (default 1 — no backoff).


readonly optional maxDelayMs?: number

Defined in: src/pattern/retry.ts:9

Upper bound for any individual retry delay.


readonly optional onAttempt?: (err, attempt) => void

Defined in: src/pattern/retry.ts:16

Called after each failed attempt; useful for logging/metrics.

Error

number

void


readonly optional shouldRetry?: (err, attempt) => boolean

Defined in: src/pattern/retry.ts:14

Predicate that decides whether a specific error is retryable. Return false to short-circuit with the final error. Defaults to “retry any”.

Error

number

boolean


readonly optional sleep?: (ms) => Promise<void>

Defined in: src/pattern/retry.ts:25

How the delay between attempts is awaited. Defaults to setTimeout. Override to take the retry loop off the wall clock — a ManualScheduler-backed sleep makes the backoff schedule exact and instant in tests, where a real timer’s ±quantum jitter makes a capped delay indistinguishable from an uncapped one. Same escape hatch as BackoffPolicy’s random.

number

Promise<void>