RetryOptions: {
    limit: number;
    methods: Method[];
    statusCodes: number[];
    errorCodes: string[];
    calculateDelay: RetryFunction;
    backoffLimit: number;
    noise: number;
    maxRetryAfter?: number;
}

An object representing limit, calculateDelay, methods, statusCodes, maxRetryAfter and errorCodes fields for maximum retry count, retry handler, allowed methods, allowed status codes, maximum Retry-After time and allowed error codes.

Delays between retries counts with function 1000 * Math.pow(2, retry) + Math.random() * 100, where retry is attempt number (starts from 1).

The calculateDelay property is a function that receives an object with attemptCount, retryOptions, error and computedValue properties for current retry count, the retry options, error and default computed value. The function must return a delay in milliseconds (or a Promise resolving with it) (0 return value cancels retry).

By default, it retries only on the specified methods, status codes, and on these network errors:

  • ETIMEDOUT: One of the timeout limits were reached.
  • ECONNRESET: Connection was forcibly closed by a peer.
  • EADDRINUSE: Could not bind to any free port.
  • ECONNREFUSED: Connection was refused by the server.
  • EPIPE: The remote side of the stream being written has been closed.
  • ENOTFOUND: Couldn't resolve the hostname to an IP address.
  • ENETUNREACH: No internet connection.
  • EAI_AGAIN: DNS lookup timed out.

Note: Got does not retry on POST by default. Note: If maxRetryAfter is set to undefined, it will use options.timeout. Note: If Retry-After header is greater than maxRetryAfter, it will cancel the request.