Skip to content

Commit

Permalink
Fix "Unknown HTTP2 promise event"
Browse files Browse the repository at this point in the history
  • Loading branch information
xc2 committed Oct 4, 2024
1 parent 9ab4cf9 commit dd39ee2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1001,13 +1001,13 @@ export default class Request extends Duplex implements RequestEvents<Request> {
handler(error);
}
})();
} else if (event === 'abort') {
} else if (event === 'abort' || event === 'destroy') {
// The empty catch is needed here in case when
// it rejects before it's `await`ed in `_makeRequest`.
(async () => {
try {
const request = (await result) as ClientRequest;
request.once('abort', handler);
request.once(event, handler);
} catch {}
})();
} else {
Expand Down
9 changes: 9 additions & 0 deletions test/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ test('doesn\'t cache response when received HTTP error', withServer, async (t, s
t.is(body, 'ok');
});

test('cache should work with http2', async t => {
const instance = got.extend({
cache: true,
http2: true,
});

await t.notThrowsAsync(instance('https://example.com'));
});

test('DNS cache works', async t => {
const instance = got.extend({
dnsCache: true,
Expand Down

0 comments on commit dd39ee2

Please sign in to comment.