API reference

retry

Retry policies and backoff strategies.

Overview

Tempo retries requests that fail with a network error, a timeout, or a status in retryOn. Non-idempotent methods (POST, PATCH) are only retried when you opt in.

Options

  • attemptsDefault 3
    number
    Tries in total, including the first.
  • backoffDefault "exponential"
    "fixed" | "linear" | "exponential"
    How the delay grows between tries.
  • delayDefault 300
    number
    Base delay in milliseconds.
  • jitterDefault true
    boolean
    Adds up to 20% at random, so clients don't retry in step.
  • retryOnDefault [408, 429, 500, 502, 503, 504]
    number[]
    Statuses that trigger a retry.
  • methodsDefault ["GET", "PUT", "DELETE"]
    string[]
    Methods that may be retried.
OptionTypeDefault
attempts
Tries in total, including the first.
number3
backoff
How the delay grows between tries.
"fixed" | "linear" | "exponential""exponential"
delay
Base delay in milliseconds.
number300
jitter
Adds up to 20% at random, so clients don't retry in step.
booleantrue
retryOn
Statuses that trigger a retry.
number[][408, 429, 500, 502, 503, 504]
methods
Methods that may be retried.
string[]["GET", "PUT", "DELETE"]

Retry-After

A 429 or 503 with a Retry-After header waits as long as the server asks, up to timeout, instead of the backoff delay.

Per-request overrides

ts
await api.post("/payments", {  body,  retry: { attempts: 2, methods: ["POST"] },});

Retry a POST only with an idempotency key

Otherwise a timeout after the server committed charges twice. Send an Idempotency-Key header the server checks.

Was this page helpful?

Updated