retry
retry(
config?):Policy
Defined in: src/policies/resilience/retry.ts:85
Retry failed upstream calls with configurable backoff.
After next() completes, checks the response status against retryOn
codes. If a retry is warranted and a _proxyRequest is available on the
context (set by createUrlUpstream() in gateway.ts), the policy clones
the stored request and calls fetch() directly — fully concurrency-safe
with no globalThis.fetch patching.
For handler-based or service-binding upstreams (no _proxyRequest), the
retry policy is a no-op since there is no stored request to re-issue.
Sets X-Retry-Count on the response when retries occur.
Parameters
Section titled “Parameters”config?
Section titled “config?”Retry limits, backoff strategy, and retryable status codes.
Returns
Section titled “Returns”A Policy at priority 90 (runs late, wraps the upstream fetch).
Example
Section titled “Example”// Retry 502/503/504 up to 3 times with exponential backoffretry();
// Fixed 500ms delay, retry on 500 tooretry({ maxRetries: 2, retryOn: [500, 502, 503, 504], backoff: "fixed", baseDelayMs: 500,});