-
-
Couldn't load subscription status.
- Fork 33.6k
Description
/cc @mcollina @addaleax @mafintosh @nodejs/http2
Currently in ServerHttp2Stream, when respondWithFile() or respondWithFD() are called, the Writable side of the Duplex is closed, causing the finish event to be emitted even tho data is still actually flowing (albeit at the C++ layer). Other than the close event, there is currently no way for user code to know when the Http2Stream is done sending the data internally, and by the time we get the close event, there's nothing else that can be done with the Http2Stream because it's... well... closed.
When using the Duplex writable side, when finish is called the Http2Stream 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() or end() on the Http2Stream after calling either of the respondWithFile() or respondWithFD() methods. Both should raise an error because the user is explicitly opting out of using the Writable API at that point.
So there are a couple of todo's here:
-
Throw if
write()orend()is called onHttp2Streamby user code afterrespondWithFile()orrespondWithFD()are used. -
Emit
finishon theHttp2Streamafter 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)