You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Timeout in milliseconds for getting a response, including any retries. Can not be greater than 2147483647.
387
-
If set to `false`, there will be no timeout.
386
+
Per-attempt timeout in milliseconds for getting a response, applied independently to each retry. Cannot be greater than 2147483647. See also [`totalTimeout`](#totaltimeout).
387
+
388
+
If set to `false`, there will be no per-attempt timeout.
389
+
390
+
##### totalTimeout
391
+
392
+
Type: `number | false`\
393
+
Default: `false`
394
+
395
+
Overall timeout in milliseconds for the entire operation, including retries and delays. Throws a `TimeoutError` if exceeded. Cannot be greater than 2147483647.
396
+
397
+
If set to `false` or not specified, there is no overall timeout.
398
+
399
+
```js
400
+
importkyfrom'ky';
401
+
402
+
// Each attempt gets 5s, but the whole operation must complete within 30s
Copy file name to clipboardExpand all lines: source/core/Ky.ts
+78-26Lines changed: 78 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,7 @@ import {
37
37
38
38
constmaxErrorResponseBodySize=10*1024*1024;
39
39
constprefixUrlRenamedErrorMessage='The `prefixUrl` option has been renamed `prefix` in v2 and enhanced to allow slashes in input. See also the new `baseUrl` option for improved flexibility with standard URL resolution: https://github.com/sindresorhus/ky#baseurl';
Copy file name to clipboardExpand all lines: source/types/options.ts
+28-3Lines changed: 28 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -187,13 +187,38 @@ export type KyOptions = {
187
187
retry?: RetryOptions|number;
188
188
189
189
/**
190
-
Timeout in milliseconds for getting a response, including any retries. Can not be greater than 2147483647.
191
-
If set to `false`, there will be no timeout.
190
+
Per-attempt timeout in milliseconds for getting a response, applied independently to each retry. Cannot be greater than 2147483647. See also `totalTimeout`.
191
+
192
+
If set to `false`, there will be no per-attempt timeout.
192
193
193
194
@default 10000
194
195
*/
195
196
timeout?: number|false;
196
197
198
+
/**
199
+
Overall timeout in milliseconds for the entire operation, including retries and delays. Throws a `TimeoutError` if exceeded. Cannot be greater than 2147483647.
200
+
201
+
If set to `false` or not specified, there is no overall timeout.
202
+
203
+
@default false
204
+
205
+
@example
206
+
```
207
+
import ky from 'ky';
208
+
209
+
// Each attempt gets 5s, but the whole operation must complete within 30s
210
+
const json = await ky('https://example.com', {
211
+
timeout: 5000,
212
+
totalTimeout: 30_000,
213
+
retry: {
214
+
limit: 3,
215
+
retryOnTimeout: true,
216
+
}
217
+
}).json();
218
+
```
219
+
*/
220
+
totalTimeout?: number|false;
221
+
197
222
/**
198
223
Hooks allow modifications during the request lifecycle. Hook functions may be async and are run serially.
0 commit comments