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

HTTP2 request opened at same time Close is called throws #25168

Closed
caleblloyd opened this issue Aug 23, 2024 · 1 comment · Fixed by #25170
Closed

HTTP2 request opened at same time Close is called throws #25168

caleblloyd opened this issue Aug 23, 2024 · 1 comment · Fixed by #25170
Labels
bug Something isn't working correctly node compat

Comments

@caleblloyd
Copy link
Contributor

Version: Deno 1.46.0

const url = "http://127.0.0.1:4246";
const client = http2.connect(url)

// leave a request open to prevent immediate destroy
const req = client.request();
req.on("data", () => {});
req.on("error", (err) => console.error(err));
const reqClosePromise = Promise.withResolvers<void>();
req.on("close", () => { reqClosePromise.resolve() });

client.close();

await reqClosePromise.promise

Throws:

error: (in promise) BadResource: Bad resource ID

I will send a PR with a test and a fix

@kt3k
Copy link
Member

kt3k commented Aug 27, 2024

Note: It looks that the example needs to be like the below to cause BadResource: Bad resource ID:

import http2 from "node:http2";
const url = "http://127.0.0.1:4246";
const connectPromise = Promise.withResolvers();
const client = http2.connect(url, {}, () => {
  connectPromise.resolve();
})

await connectPromise.promise

// leave a request open to prevent immediate destroy
const req = client.request();
req.on("data", () => {});
req.on("error", (err) => console.error(err));
const reqClosePromise = Promise.withResolvers();
req.on("close", () => { reqClosePromise.resolve() });

client.close();

await reqClosePromise.promise

@lucacasonato lucacasonato added bug Something isn't working correctly node compat labels Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants