-
Notifications
You must be signed in to change notification settings - Fork 30k
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: respondWithFile/respondWithFD events and stream API interaction #20014
Comments
Just for context, I am still going to work on giving Since that would be a fast path for |
Sounds like you should impl _final and have it wait for everything to close down nicely before calling it's cb. That'll make finish emit only after the stream is fully done but any subsequent calls to write will throw as they should |
Oh nice, that may be exactly what we need. I'll investigate that a bit. |
Added benefit is that you become a good stream citizen and all the tooling will work as expected with http2 streams |
/cc @mcollina @addaleax @mafintosh @nodejs/http2
Currently in
ServerHttp2Stream
, whenrespondWithFile()
orrespondWithFD()
are called, theWritable
side of theDuplex
is closed, causing thefinish
event to be emitted even tho data is still actually flowing (albeit at the C++ layer). Other than theclose
event, there is currently no way for user code to know when theHttp2Stream
is done sending the data internally, and by the time we get theclose
event, there's nothing else that can be done with theHttp2Stream
because it's... well... closed.When using the
Duplex
writable side, whenfinish
is called theHttp2Stream
is not yet closed so there are still things that can be done with it.A second issue is that user code should not call
write()
orend()
on theHttp2Stream
after calling either of therespondWithFile()
orrespondWithFD()
methods. Both should raise an error because the user is explicitly opting out of using theWritable
API at that point.So there are a couple of todo's here:
Throw if
write()
orend()
is called onHttp2Stream
by user code afterrespondWithFile()
orrespondWithFD()
are used.Emit
finish
on theHttp2Stream
after the C++ side is done writing the data from the FD but before the stream is closed.As an alternative to emitting
finish
, therespondWithFile()
andrespondWithFD()
calls could take a callback that is invoked when the data send is complete and before the stream is closed. (Personally this one would be my preference)The text was updated successfully, but these errors were encountered: