You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consth2=require('http2');constserver=h2.createServer();server.on('stream',(stream)=>{stream.session.destroy();});server.listen(0,()=>{constclient=h2.connect(`http://localhost:${server.address().port}`);client.on('close',()=>{server.close();;});constclientStream=client.request();clientStream.on('aborted',()=>{// Never calledconsole.log('aborted');});clientStream.on('close',()=>{// `rstCode === 8 (NGHTTP2_CANCEL) console.log('close',clientStream.rstCode);});clientStream.on('error',(err)=>{// Never calledthrowerr;});});
in which clientStream is aborted before any response is generated via the stream.session.destroy() call. I would expect in this case clientStream to emit an error, but by looking at the code, this specific case is explicitly not reporting the error because:
// RST code 8 not emitted as an error as its used by clients to signify
// abort and is already covered by aborted event, also allows more
// seamless compatibility with http1
but, as demonstrated in the example, the aborted event is not reported. I don't know exactly what the http1 compatibility means in this context.
Also, if we look at the documentation of the Http2Streamclose event, it seems to contradict the following statement:
The HTTP/2 error code used when closing the stream can be retrieved using the http2stream.rstCode property. If the code is any value other than NGHTTP2_NO_ERROR (0), an 'error' event will have also been emitted.
Any thoughts whether this is a bug in the code, the documentation, both?.
Thanks!
The text was updated successfully, but these errors were encountered:
IMO, this seems to be a bug in the code, but it might be a workaround instead due to the number of tests that break if we revert that operation. I'd defer the suggestion to @mcollina@jasnell@addaleax, but in case of no response, I'd try to emit a stream error in that scenario.
Take this sample code:
in which
clientStream
is aborted before any response is generated via thestream.session.destroy()
call. I would expect in this caseclientStream
to emit anerror
, but by looking at the code, this specific case is explicitly not reporting the error because:but, as demonstrated in the example, the
aborted
event is not reported. I don't know exactly what the http1 compatibility means in this context.Also, if we look at the documentation of the
Http2Stream
close
event, it seems to contradict the following statement:Any thoughts whether this is a bug in the code, the documentation, both?.
Thanks!
The text was updated successfully, but these errors were encountered: