-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
http2: skip writeHead if stream is closed #57686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
Review requested:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #57686 +/- ##
==========================================
+ Coverage 90.22% 90.24% +0.01%
==========================================
Files 630 630
Lines 185074 185074
Branches 36222 36221 -1
==========================================
+ Hits 166985 167013 +28
+ Misses 11041 11034 -7
+ Partials 7048 7027 -21
🚀 New features to boost your workflow:
|
lpinca
approved these changes
Mar 30, 2025
pimterry
approved these changes
Mar 31, 2025
mcollina
approved these changes
Mar 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
RafaelGSS
approved these changes
Mar 31, 2025
ec39cfd
to
ddca2b5
Compare
jakecastelli
approved these changes
Apr 4, 2025
Landed in b140283 |
JonasBa
pushed a commit
to JonasBa/node
that referenced
this pull request
Apr 11, 2025
Fixes: nodejs#57416 PR-URL: nodejs#57686 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
author ready
PRs that have at least one approval, no pending requests for changes, and a CI started.
http2
Issues or PRs related to the http2 subsystem.
needs-ci
PRs that need a full CI run.
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.
Fixes: #57416
This issue can be reproduced by destroying the session immediately after the client sends a request.
You may occasionally see an error after running it a few times.
seq 100 | xargs -n1 -P100 node client.js
If writeHead() is called after the server receives a GOAWAY frame but before it sends a RST_STREAM, the server may enter an error state.
After the GOAWAY frame is received, the http2Stream is immediately closed.
However, the response object (res) is only marked as closed after the RST_STREAM frame is sent.
Currently, writeHead() checks whether the response object is closed, but it does not check whether the stream itself has been closed.
how to fix
Even if the RST_STREAM frame hasn't been sent yet, it seems like it might already be queued when the http2Stream is closed.
So this change skips writeHead() when the stream is already closed.