fix(h2): ignore late data frames after request completion#4845
Merged
metcoder95 merged 1 commit intomainfrom Mar 4, 2026
Merged
fix(h2): ignore late data frames after request completion#4845metcoder95 merged 1 commit intomainfrom
metcoder95 merged 1 commit intomainfrom
Conversation
Guard the HTTP/2 data handler when a request is already completed or aborted and remove data listeners before completing from trailers. Adds a regression test covering trailers followed by late data without crashing. Fixes: #4843
hxinhan
reviewed
Mar 1, 2026
| // the request remains in-flight and headers hasn't been received yet | ||
| // for those scenarios, best effort is to destroy the stream immediately | ||
| // as there's no value to keep it open. | ||
| if (request.aborted) { |
Contributor
There was a problem hiding this comment.
Should we also check if request is complete here?
hxinhan
reviewed
Mar 1, 2026
Contributor
hxinhan
left a comment
There was a problem hiding this comment.
Thanks for looking into this bug report. I left a comment about potential request completion check in additional call path
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4845 +/- ##
==========================================
- Coverage 93.19% 93.13% -0.06%
==========================================
Files 109 109
Lines 34222 34244 +22
==========================================
+ Hits 31893 31894 +1
- Misses 2329 2350 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
metcoder95
approved these changes
Mar 2, 2026
hxinhan
approved these changes
Mar 3, 2026
Contributor
|
Should we merge the PR now? |
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.
Description
Fixes a crash in the HTTP/2 dispatcher when a late
dataevent arrives after the request has already completed.In
client-h2,stream.on('data')calledrequest.onData()unconditionally. If completion happened first (for example viatrailers),request.onData()could hit the internalassert(!this.completed)and crash the process.This change:
datahandler whenrequest.aborted || request.completeddatalisteners before invokingrequest.onComplete(trailers)in thetrailerspathresponse -> trailers -> late dataFixes: #4843
Testing
npx borp -p "test/http2-late-data.js"npx borp -p "test/http2-trailers.js"npx borp -p "test/http2-dispatcher.js"npm run lint