http2: fix onread assert when destroying session from stream handler - #65116
Open
sankalpsthakur wants to merge 1 commit into
Open
http2: fix onread assert when destroying session from stream handler#65116sankalpsthakur wants to merge 1 commit into
sankalpsthakur wants to merge 1 commit into
Conversation
When session.destroy() runs from a 'stream' handler, MakeCallback drains nextTick while nghttp2 is still inside mem_recv. Close is deferred for that window (see nodejs#64166), so later HEADERS in the same buffer created C++ streams without a JS wrapper or onread, and DATA delivery aborted with Assertion failed: onread->IsFunction(). - Reject new streams while the session is closing - Destroy the C++ handle if on_headers runs after JS destroy - Drop DATA when onread is not installed (defensive) Fixes: nodejs#64850 Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
Collaborator
|
Review requested:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
session.destroy()is called from a'stream'handler,MakeCallbackdrainsnextTickwhile nghttp2 is still insidemem_recv. Session close is deferred for that window (from #64166), so later HEADERS in the same receive buffer created C++ streams without a JS wrapper /onread. Subsequent DATA delivery hit:Changes
OnBeginHeadersCallback) — RST withNGHTTP2_CANCELinstead.on_headersruns after JS destroy, destroy the C++ handle (mirrors the existingsession.closedpath).onreadis not a function rather than aborting.session.destroy()from the stream handler.Test plan
test/parallel/test-http2-session-destroy-stream-handler.js(40 rounds × 8 concurrent POSTs)Fixes #64850
AI/LLM disclosure