Skip to content

RetryConfig

Defined in: src/core/types.ts:262

optional maxRetries?: number

Defined in: src/core/types.ts:266

Retries after the first attempt. MaxRetriesExceededError.attempts is total executions, i.e. maxRetries + 1.

DEFAULT_MAX_RETRIES


optional backoff?: BackoffOptions | BackoffFn

Defined in: src/core/types.ts:268

{ baseDelayMs: 200, maxDelayMs: 30_000, jitter: true }


optional retryOnStatus?: number[]

Defined in: src/core/types.ts:271

HTTP status codes that trigger retry (e.g. 408, 429, 500, 502, 503, 504).

DEFAULT_RETRY_ON_STATUS


optional idempotent?: boolean

Defined in: src/core/types.ts:274

Allows retrying non-idempotent methods (POST/PATCH). An Idempotency-Key header also enables retries. Default: false.


optional idempotencyKey?: boolean | (() => string)

Defined in: src/core/types.ts:285

Sends an Idempotency-Key header so a POST/PATCH can be retried safely. Off by default. true generates a random v4 UUID key; a function returns your own key. One key is generated per request, before the first attempt, and the same key is sent on every attempt. Only requests with a non-idempotent method (not GET, HEAD, OPTIONS, PUT or DELETE) get one, and a request that already has an Idempotency-Key non-empty header keeps the caller’s value. The key is added even when maxRetries is 0. A generator that throws or returns a blank or non-string value fails the request with a ConfigurationError. Default: false.


optional retryWhen?: (error, attempt) => boolean

Defined in: src/core/types.ts:294

Optional predicate to decide whether a failed attempt should be retried. Called exactly once per failed attempt that could still be retried, with the zero-based attempt number:

  • 0 = the first attempt (called client-side before the retry loop)
  • 1, 2, … = retries (called inside the loop, after attempt 0) Returning false surfaces the error immediately without retrying. Not called after the final attempt when no retries remain — there is nothing left to decide.

AppError

number

boolean