Import it from ky.
tstype RetryOptions = { … }
Properties
| Name | Type | Default | Description |
|---|---|---|---|
limit? | number | undefined | 2 | The number of times to retry failed requests. Must be a finite, non-negative integer. |
methods? | readonly HttpMethod[] | undefined | ['get', 'put', 'head', 'delete', 'options', 'trace', 'query'] | The HTTP methods allowed to retry. |
statusCodes? | readonly number[] | undefined | [408, 413, 429, 500, 502, 503, 504] | The HTTP status codes allowed to retry. |
afterStatusCodes? | readonly number[] | undefined | [413, 429, 503] | The retriable HTTP status codes that should respect retry timing headers. These status codes must also be included in statusCodes. |
maxRetryAfter? | number | undefined | Infinity | If the retry delay from a retry timing header is greater than maxRetryAfter, Ky will use maxRetryAfter. |
backoffLimit? | number | undefined | Infinity | The upper limit of the delay per retry in milliseconds. To clamp the delay, set backoffLimit to 1000, for example. |
delay? | ((attemptCount: number) => number) | undefined | attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000 | A function to calculate the delay in milliseconds between retries given attemptCount (starts from 1). |
jitter? | boolean | ((delay: number) => number) | undefined | undefined (no jitter) | Add random jitter to retry delays to prevent thundering herd problems. |
retryOnTimeout? | boolean | undefined | false | Whether to retry when the request times out before a response is returned. Timeouts while reading a response body through Ky shortcut methods are not retried because the response has already been received. |
shouldRetry? | ((state: ShouldRetryState) => boolean | void | Promise<boolean | void>) | undefined | undefined | A function to determine whether a retry should be attempted. |
Was this page helpful?