qfetch
    Preparing search index...

    Function withRetryAfter

    • Middleware that retries requests based on server-provided Retry-After headers.

      Parameters

      Returns MiddlewareExecutor

      Handles server-directed retry timing for rate limiting and temporary unavailability. When a retryable response includes a valid Retry-After header, the middleware parses the delay (supporting both delay-seconds and HTTP-date formats per RFC 9110) and waits before retrying. The total wait time is Retry-After + strategy backoff.

      Responses without Retry-After headers or with invalid values are returned as-is.

      ConstraintError when server delay exceeds maxServerDelay.

      If the request's AbortSignal is aborted during retry delay.

      If total delay exceeds maximum safe timeout (~24.8 days).

      import { withRetryAfter } from "@qfetch/middleware-retry-after";
      import { fullJitter, upto } from "@proventuslabs/retry-strategies";

      const qfetch = withRetryAfter({
      strategy: () => upto(3, fullJitter(100, 10_000))
      })(fetch);