Skip to content

Commit eefcde5

Browse files
authoredMay 4, 2021
Throw timeouts even if throwHttpErrors is false (#334)
1 parent ca098f8 commit eefcde5

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed
 

‎source/core/Ky.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ export class Ky {
248248
return this._retry(fn);
249249
}
250250

251-
if (this._options.throwHttpErrors) {
252-
throw error;
253-
}
251+
throw error;
254252
}
255253
}
256254

‎test/main.ts

+20
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,26 @@ test('throwHttpErrors option with POST', async t => {
393393
await server.close();
394394
});
395395

396+
test('throwHttpErrors:false does not suppress timeout errors', async t => {
397+
let requestCount = 0;
398+
399+
const server = await createHttpTestServer();
400+
server.get('/', async (_request, response) => {
401+
requestCount++;
402+
await delay(1000);
403+
response.sendStatus(500);
404+
});
405+
406+
await t.throwsAsync(
407+
ky(server.url, {throwHttpErrors: false, timeout: 500}).text(),
408+
{instanceOf: ky.TimeoutError}
409+
);
410+
411+
t.is(requestCount, 1);
412+
413+
await server.close();
414+
});
415+
396416
test('ky.create()', async t => {
397417
const server = await createHttpTestServer();
398418
server.get('/', (request, response) => {

0 commit comments

Comments
 (0)