Skip to content
Myr

Throw timeouts even if throwHttpErrors is false (#334)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Seth Holladay · committed by GitHub · parent ca098f8 · Browse files · 2 files+21 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+21 added−3 removed

  • tests:+20 added−0 removed
  • other:+1 added−3 removed

2 files+21 added−3 removed

modified:source/core/Ky.ts+1 added-3 removed
246 unmodified lines
247248 return this._retry(fn);249 }250251 if (this._options.throwHttpErrors) {252 throw error;251 throw error;253 }252 }253 }254255 protected async _fetch(): Promise<Response> {
58 unmodified lines
modified:test/main.ts+20 added
391 unmodified lines
392393 await server.close();394});395396test('throwHttpErrors:false does not suppress timeout errors', async t => {397 let requestCount = 0;398399 const server = await createHttpTestServer();400 server.get('/', async (_request, response) => {401 requestCount++;402 await delay(1000);403 response.sendStatus(500);404 });405406 await t.throwsAsync(407 ky(server.url, {throwHttpErrors: false, timeout: 500}).text(),408 {instanceOf: ky.TimeoutError}409 );410411 t.is(requestCount, 1);412413 await server.close();414});415416test('ky.create()', async t => {417 const server = await createHttpTestServer();418 server.get('/', (request, response) => {419 // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
260 unmodified lines