1 | export type RetryOptions = {
|
2 | /**
|
3 | The number of times to retry failed requests.
|
4 |
|
5 | @default 2
|
6 | */
|
7 | limit?: number;
|
8 | /**
|
9 | The HTTP methods allowed to retry.
|
10 |
|
11 | @default ['get', 'put', 'head', 'delete', 'options', 'trace']
|
12 | */
|
13 | methods?: string[];
|
14 | /**
|
15 | The HTTP status codes allowed to retry.
|
16 |
|
17 | @default [408, 413, 429, 500, 502, 503, 504]
|
18 | */
|
19 | statusCodes?: number[];
|
20 | /**
|
21 | The HTTP status codes allowed to retry with a `Retry-After` header.
|
22 |
|
23 | @default [413, 429, 503]
|
24 | */
|
25 | afterStatusCodes?: number[];
|
26 | /**
|
27 | If the `Retry-After` header is greater than `maxRetryAfter`, the request will be canceled.
|
28 |
|
29 | @default Infinity
|
30 | */
|
31 | maxRetryAfter?: number;
|
32 | /**
|
33 | The upper limit of the delay per retry in milliseconds.
|
34 | To clamp the delay, set `backoffLimit` to 1000, for example.
|
35 |
|
36 | By default, the delay is calculated in the following way:
|
37 |
|
38 | ```
|
39 | 0.3 * (2 ** (attemptCount - 1)) * 1000
|
40 | ```
|
41 |
|
42 | The delay increases exponentially.
|
43 |
|
44 | @default Infinity
|
45 | */
|
46 | backoffLimit?: number;
|
47 | /**
|
48 | A function to calculate the delay between retries given `attemptCount` (starts from 1).
|
49 |
|
50 | @default attemptCount => 0.3 * (2 ** (attemptCount - 1)) * 1000
|
51 | */
|
52 | delay?: (attemptCount: number) => number;
|
53 | };
|