Repository navigation
Conversation
|
Hi @xiehuanyi! Thanks for the fix - this descriptor leak on failed reads is real, and your patch looks good. Sadly, cross-spawn doesn't seem to be actively maintained anymore. If you're still using it, I maintain Thanks again! |
satazor
added a commit
that referenced
this pull request
Nov 1, 2026
readShebang only closed the file descriptor after a successful read, so it leaked when fs.readSync threw, e.g.: when the file is a directory. Based on #184. Co-authored-by: Huanyi Xie <74809554+xiehuanyi@users.noreply.github.com>
satazor
added a commit
that referenced
this pull request
Nov 1, 2026
readShebang only closed the file descriptor after a successful read, so it leaked when fs.readSync threw, e.g.: when the file is a directory. Based on #184. Co-authored-by: Huanyi Xie <74809554+xiehuanyi@users.noreply.github.com>
Contributor
|
landed in #187 Thanks! |
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.
readShebangcloses its file descriptor only after a successful read. Iffs.readSyncthrows (for example, when a directory is encountered), the error is ignored but the opened descriptor leaks.Close opened descriptors in
finally, including descriptor zero. Read and close failures retain the existing non-throwing fallback, and failed opens do not attempt a close.The new read-failure regression fails on the original code. Additional checks cover failed opens, close errors, and a valid shebang. Validation on Node 22:
npm test -- --runInBandpasses all 72 tests;npm run lintandgit diff --checkpass.