Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Unknown HTTP2 promise event" #2380

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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