diff --git a/source/core/Ky.ts b/source/core/Ky.ts index d9a387e6..bba03fb0 100644 --- a/source/core/Ky.ts +++ b/source/core/Ky.ts @@ -248,9 +248,7 @@ export class Ky { return this._retry(fn); } - if (this._options.throwHttpErrors) { - throw error; - } + throw error; } } diff --git a/test/main.ts b/test/main.ts index 4470b8a7..f7781b2f 100644 --- a/test/main.ts +++ b/test/main.ts @@ -393,6 +393,26 @@ test('throwHttpErrors option with POST', async t => { await server.close(); }); +test('throwHttpErrors:false does not suppress timeout errors', async t => { + let requestCount = 0; + + const server = await createHttpTestServer(); + server.get('/', async (_request, response) => { + requestCount++; + await delay(1000); + response.sendStatus(500); + }); + + await t.throwsAsync( + ky(server.url, {throwHttpErrors: false, timeout: 500}).text(), + {instanceOf: ky.TimeoutError} + ); + + t.is(requestCount, 1); + + await server.close(); +}); + test('ky.create()', async t => { const server = await createHttpTestServer(); server.get('/', (request, response) => {