Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

RequestDelayFunction

RequestDelayFunction: (attempt: number, error: Error | null, response: Response | null) => number

Type declaration

    • (attempt: number, error: Error | null, response: Response | null): number
    • The type signature for fetch's retryDelay function.

      Parameters

      • attempt: number
      • error: Error | null
      • response: Response | null

      Returns number

RequestRetryOnFunction

RequestRetryOnFunction: (attempt: number, error: Error | null, response: Response | null) => boolean | Promise<boolean>

Type declaration

    • (attempt: number, error: Error | null, response: Response | null): boolean | Promise<boolean>
    • The type signature for fetch's retryOn function.

      Parameters

      • attempt: number
      • error: Error | null
      • response: Response | null

      Returns boolean | Promise<boolean>

Functions

Const exponentialDelay

  • exponentialDelay(attempt: number): number
  • The default exponential backoff delay function used by fetch when it needs to retry a request.

    Note that since Functions are limited to 10 seconds of runtime, requests that use this delay function can only retry a maximum of 4 times (8 seconds).

    Parameters

    • attempt: number

    Returns number

Const fetch

  • An implementation of the Fetch API. This Fetch implementation supports automatic retries on failure with (by default) exponential backoff, in addition to the standard Fetch API features.

    Note that Functions are limited to 10 seconds of runtime, which imposes a cap on the maximum number of retries and amount of time between retries for failed requests. The default delay function allows for a maximum number of 4 retries before the Function times out, but other requests and time spent executing code will lower the practical maximum.

    Usage: const response = await fetch(url, options);

    The options object supports the following non-standard fields:

    retries: The number of retries to attempt (default 0; no retries)
    retryDelay: A function or number used to calculate the number of milliseconds to delay between retries (default exponentialDelay)
    retryOn: An array of HTTP status codes that cause a retry (defaults to the set of network-related status codes)

    Parameters

    Returns Promise<Response>

Generated using TypeDoc