Documentation
    Preparing search index...

    Interface RetryOptions

    interface RetryOptions {
        afterStatusCodes?: number[];
        factor?: number;
        maxRetryTime?: number;
        maxTimeout?: number;
        methods?: string[];
        minTimeout?: number;
        randomize?: boolean;
        retries?: number;
        shouldRetry?: (context: ShouldRetryContext) => boolean | Promise<boolean>;
        statusCodes?: number[];
        unref?: boolean;
    }
    Index
    afterStatusCodes?: number[]

    The status codes to retry after

    Request will wait until the date or number of seconds given in the Retry-After header has passed to retry the request. If Retry-After is missing, the non-standard RateLimit-Reset header (seconds) is used in its place as a fallback, then X-RateLimit-Reset or X-Rate-Limit-Reset (Unix timestamp in seconds). If the provided status code is not in the list, the Retry-After header will be ignored.

    The wait only happens when the request will be retried, and it replaces the backoff delay. If the wait doesn't fit in the remaining timeout or maxRetryTime, the HttpError is returned right away. Retries after a Retry-After wait count against retries.

    [413, 429, 503]
    
    factor?: number

    The exponential factor to use.

    2
    
    maxRetryTime?: number

    The maximum time (in milliseconds) that the retried operation is allowed to run.

    Infinity
    
    maxTimeout?: number

    The maximum number of milliseconds between two retries.

    Infinity
    
    methods?: string[]

    The methods to retry. Both statusCodes and network errors are only retried for these methods, so non-idempotent methods like POST and PATCH are not retried unless added here or allowed by shouldRetry.

    ['get', 'put', 'head', 'delete', 'options', 'trace']
    
    minTimeout?: number

    The number of milliseconds before starting the first retry.

    1000
    
    randomize?: boolean

    Randomizes the timeouts by multiplying a factor between 1-2.

    false
    
    retries?: number

    The maximum amount of times to retry the operation.

    When poll is also enabled, each retry reruns the whole polling loop and restarts its counter, so up to (retries + 1) × poll.limit requests can be made. The default timeout is sized for that worst case.

    2
    
    shouldRetry?: (context: ShouldRetryContext) => boolean | Promise<boolean>

    Decide whether to retry a failed attempt. Called for every failure while retries are left, and its return value replaces the built-in checks (methods, statusCodes and network errors).

    context.defaultShouldRetry holds the built-in decision, so return it to keep the default behavior. Return true to retry requests the built-in checks would not, for example an idempotent POST. retries and maxRetryTime still apply.

    When the request is retried, the body of the failed response is cancelled after this hook returns. Read it inside the hook, or clone it to keep it.

    Type Declaration

      • (context: ShouldRetryContext): boolean | Promise<boolean>
      • Parameters

        Returns boolean | Promise<boolean>

        • Whether to retry the request
    statusCodes?: number[]

    The HTTP status codes to retry on. Status codes in the range 400-599.

    [408, 413, 429, 500, 502, 503, 504]
    
    unref?: boolean

    Whether to unref the setTimeout's.

    false