Skip to content
Français

Retry

import type { Retry } from "@elie-laloum/outpost";
  • attemptsRequired
    number
    Maximum attempts, the first included; a positive integer. The count restarts when the task runs again after a quota pause or a checkpoint resume.
  • delayMsOptional
    number | undefined
    Wait in milliseconds before each retry, default 0.
  • backoffOptional
    "fixed" | "exponential" | undefined
    Delay strategy: fixed (default) keeps delayMs; exponential doubles it after each failed attempt.
  • maxDelayMsOptional
    number | undefined
    Nonnegative local delay cap, applied before jitter. Defaults to 30000 ms for exponential backoff; fixed delays have no additional cap. A valid server retryAfterMs minimum can exceed it.
  • jitterOptional
    "none" | "full" | undefined
    Randomization: none by default; full samples uniformly from zero to the capped local delay. The server retry minimum is applied afterwards and the result rounded up to milliseconds.
  • acceptsOptional
    ((error: unknown, attempt: number) => boolean) | undefined
    Receives the error and the attempt number; returning false fails the task without further retries.
export interface Retry {
  readonly attempts: number;
  readonly delayMs?: number;
  readonly backoff?: "fixed" | "exponential";
  readonly maxDelayMs?: number;
  readonly jitter?: "none" | "full";
  readonly accepts?: (error: unknown, attempt: number) => boolean;
}