Skip to content

RetryPolicy

RetryPolicy<E> = object

Defined in: Types/RetryPolicy.ts:19

An immutable policy describing retry limits, backoff delay strategies, transient failure filters, and observational telemetry.

const policy: RetryPolicy<Error> = RetryPolicy.exponential({
  attempts: 3,
  initial: Duration.milliseconds(100),
  when: (err) => err.name === "NetworkError",
  onRetry: (metadata) => console.warn(`Retrying attempt ${metadata.attempt}: ${metadata.error.message}`),
});

E = unknown

readonly attempts: number

Defined in: Types/RetryPolicy.ts:24

Total number of attempts, including the first. A positive integer; 1 means no retry. Any other value is treated as one attempt.


readonly getDelay: (attempt) => Duration

Defined in: Types/RetryPolicy.ts:25

number

Duration


readonly optional onRetry?: (metadata) => void

Defined in: Types/RetryPolicy.ts:27

Metadata<E>

void


readonly optional when?: (error) => boolean

Defined in: Types/RetryPolicy.ts:26

E

boolean