fix(h2): detach upgrade close handler after GOAWAY - #5641
Merged
Conversation
Signed-off-by: pacocartones <manusanchezhl@gmail.com>
Member
|
why is it a draft? |
pacocartones
marked this pull request as ready for review
August 3, 2026 10:42
Contributor
Author
|
It’s now ready for review — thanks! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5641 +/- ##
==========================================
- Coverage 93.40% 93.40% -0.01%
==========================================
Files 110 110
Lines 38645 38648 +3
==========================================
+ Hits 36098 36099 +1
- Misses 2547 2549 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
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.
This relates to...
Fixes #5638.
Rationale
When GOAWAY marks an upgrade stream as unaccepted,
severRequestStream()already releases its HTTP/2 session. Upgrade streams also retain
onUpgradeStreamClose, which later attempts the same release after the streamcloses. The second release dereferences a cleared session and escapes as an
uncaught exception.
Detaching that upgrade-specific close handler at sever time makes the cleanup
ownership unambiguous. The request remains on the existing GOAWAY retry/error
path and settles normally.
Changes
onUpgradeStreamClosealong with the regular request close handler.lastStreamID = 0while a CONNECTstream is opening must settle rather than crash the process.
Validation
Implementation and validation used Codex assistance; I reviewed the final diff and results.
Verification
Every command below was run and its output captured verbatim. The record is reproducible — the exact commands are included so you can re-run them yourself.
red — without detaching the upgrade close handler (must fail without the fix)
green — fix intact (must pass) — 3 runs, identical exit code
Environment and output hashes
Status