Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
Description
- Version: v15.4.0
- Platform: Linux pete 5.11.13-arch1-1 deps: update openssl to 1.0.1j #1 SMP PREEMPT Sat, 10 Apr 2021 20:47:14 +0000 x86_64 GNU/Linux
- Subsystem: ?
What steps will reproduce the bug?
When making a http2 request, it seems that events are only fired for the first headers in the stream and not the following!
I encountered this problem when waiting for a response after a continue response. The first headers are the continue response so I do get an event for them. But the next headers (the actual response) do not fire an event.
The following code exposes the bug
consthttp=require("http");consthttp2=require("http2");main();asyncfunctionmain(){awaittestHttp();awaittestHttp2();}asyncfunctiontestHttp(){console.log("http test");constserver=http.createServer((request,response)=>response.end());awaitnewPromise(resolve=>server.listen(9090,resolve));conststream=http.request("http://localhost:9090/",{headers: {"expect": "100-continue",},});consterrorPromise=newPromise((resolve,reject)=>stream.addListener("error",reject));constcontinuePromise=newPromise(resolve=>stream.addListener("continue",resolve));constresponsePromise=newPromise(resolve=>stream.addListener("response",resolve));constcontinueValue=awaitPromise.race([errorPromise,continuePromise,]);console.log("continue");constresponseValue=awaitPromise.race([errorPromise,responsePromise,]);console.log("response");awaitnewPromise((resolve,reject)=>server.close(error=>error ? reject(error) : resolve()),);console.log("done");}asyncfunctiontestHttp2(){console.log("http2 test");constserver=http2.createServer((request,response)=>response.end());awaitnewPromise(resolve=>server.listen(9090,resolve));constsession=http2.connect("http://localhost:9090");conststream=session.request({":path": "/","expect": "100-continue",});consterrorPromise=newPromise((resolve,reject)=>stream.addListener("error",reject));constcontinuePromise=newPromise(resolve=>stream.addListener("continue",resolve));constresponsePromise=newPromise(resolve=>stream.addListener("response",resolve));constcontinueValue=awaitPromise.race([errorPromise,continuePromise,]);console.log("continue");constresponseValue=awaitPromise.race([errorPromise,responsePromise,]);// unfortunately we never get to here in node v15.4.0console.log("response");awaitnewPromise(resolve=>session.close(resolve),);awaitnewPromise((resolve,reject)=>server.close(error=>error ? reject(error) : resolve()),);console.log("done");}Also tried listening to the headers event of the http2 stream, this event fires only the first time (on the continue response), the next time (actuel response) there is no event.
How often does it reproduce? Is there a required condition?
reproduces every time!
What is the expected behavior?
When receiving a http continue response i expect the continue event to be fired, when receiveing a http response (other than continue) i expect the response event to be fired!
What do you see instead?
only the first headers frame causes an event to be fired. The event is correct, but the second event never happens!
Additional information
Please help! This bug makes the nodejs http2 client useless for our use case!