-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
http2: fix FileHandle leak in respondWithFile #61707
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
http2: fix FileHandle leak in respondWithFile #61707
Conversation
|
Review requested:
|
Ensure that the file handle is closed if header validation fails in respondWithFile. This prevents ERR_INVALID_STATE errors where a FileHandle object is closed during garbage collection.
4859ad9 to
5c4dd6b
Compare
mcollina
left a comment
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.
Thanks for opening a PR! Can you please add a unit test?
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61707 +/- ##
=======================================
Coverage 89.75% 89.75%
=======================================
Files 674 674
Lines 204416 204428 +12
Branches 39285 39284 -1
=======================================
+ Hits 183472 183484 +12
- Misses 13227 13241 +14
+ Partials 7717 7703 -14
🚀 New features to boost your workflow:
|
Verifies that the file descriptor is closed when an error occurs during header validation in respondWithFile. Refs: 5c4dd6b
|
Thank you for your review. I have added unit tests. |
pimterry
left a comment
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 👍
|
I think I got a flaki tI think I got a flaki test. Could you please give me the ci again? Thank you. |
|
Failed with the known flake (timeout) again. Please re-run when you get a chance. |
mcollina
left a comment
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
|
Landed in f0be1c0 |
Summary
This PR fixes a
FileHandleleak inlib/internal/http2/core.jsthat causesERR_INVALID_STATEwhen garbage collection occurs.In
processRespondWithFD, ifbuildNgHeaderStringthrows (e.g., due to invalid headers), the code would catch the error and destroy the stream but fail to close the file handle (fd) if it owned it (self.ownsFd). This leaves the file handle open, eventually triggering the GC error.This patch adds a
tryClose(fd)call in the catch block and error handling path to ensure the handle is properly released.References