Skip to content

v1.15.0

Choose a tag to compare

@terrerox terrerox released this 24 Feb 15:44
· 207 commits to master since this release
4ac58ae

Adds a retryWithBackoff utility that automatically retries HTTP requests when a 429 – Too Many
Requests response is received.

Key points

  • Retries are based on the retry-after response header.
  • Integrated into all HttpClient HTTP methods via an execute wrapper.
  • Retry is disabled by default — enable it globally through HttpClient.enableGlobalRetry, or
    per-service by passing retryOptions inside the ApiSecurity object.
  • Per-service options take priority over global options.

Behavior details

  • Retries only on 429 Too Many Requests.
  • Delay is read from the retry-after header (seconds).
  • Delay is capped at maxRetryAfter (default: 70000ms) regardless of header value.
  • If the header is missing or invalid, the error is thrown immediately.
  • After all retries are exhausted, the original error is re-thrown with a Max retries exceeded
    prefix.
  • Setting maxRetries to 0 in enableGlobalRetry is a compile-time error via the NonZero type
    constraint.

Configuration examples

// Per-service: only Storage retries
Storage.client(apiUrl, appDetails, { token, retryOptions: { maxRetries: 3 } }); 
Auth.client(apiUrl, appDetails); // no retry

// Global: all services retry
HttpClient.enableGlobalRetry({ maxRetries: 5 });

// Per-service overrides global
HttpClient.enableGlobalRetry({ maxRetries: 5 }); 
Storage.client(apiUrl, appDetails, { token, retryOptions: { maxRetries: 2 } }); // uses 2