Please sign in to comment.
http2: wait for session socket writable end on close/destroy
This slightly alters the behaviour of session close by first using .end() on a session socket to finish writing the data and only then calls .destroy() to make sure the Readable side is closed. This allows the socket to finish transmitting data, receive proper FIN packet and avoid ECONNRESET errors upon graceful close. onStreamClose now directly calls stream.destroy() instead of kMaybeDestroy because the latter will first check that the stream has writableFinished set. And that may not be true as we have just (synchronously) called .end() on the stream if it was not closed and that doesn't give it enough time to finish. Furthermore there is no point in waiting for 'finish' as the other party have already closed the stream and we won't be able to write anyway. This also changes a few tests to correctly handle graceful session close. This includes: * not reading request data (on client side) * not reading push stream data (on client side) * relying on socket.destroy() (on client) to finish server session due to the destroy of the socket without closing the server session. As the goaway itself is *not* a session close. Added few 'close' event mustCall checks. PR-URL: #30854 Reviewed-By: Matteo Collina <firstname.lastname@example.org> Reviewed-By: Anna Henningsen <email@example.com> Reviewed-By: James M Snell <firstname.lastname@example.org> Reviewed-By: Rich Trott <email@example.com>
- Loading branch information
Showing with 101 additions and 45 deletions.
- +71 −36 lib/internal/http2/core.js
- +1 −1 src/node_http2.cc
- +1 −1 test/parallel/test-http2-capture-rejection.js
- +1 −0 test/parallel/test-http2-client-destroy.js
- +7 −2 test/parallel/test-http2-client-stream-destroy-before-connect.js
- +2 −0 test/parallel/test-http2-compat-client-upload-reject.js
- +3 −1 test/parallel/test-http2-create-client-connect.js
- +6 −2 test/parallel/test-http2-goaway-opaquedata.js
- +7 −2 test/parallel/test-http2-ping-settings-heapdump.js
- +2 −0 test/parallel/test-http2-server-push-stream.js