fs: do not swallow exceptions thrown by completion callbacks - #66308
Open
marcopiraccini wants to merge 1 commit into
Open
marcopiraccini wants to merge 1 commit into
marcopiraccini wants to merge 1 commit into
Conversation
marcopiraccini
marked this pull request as ready for review
September 26, 2026 03:53
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66308 +/- ##
==========================================
+ Coverage 90.36% 90.39% +0.02%
==========================================
Files 790 790
Lines 274292 274275 -17
Branches 52510 52491 -19
==========================================
+ Hits 247874 247927 +53
+ Misses 16901 16837 -64
+ Partials 9517 9511 -6
🚀 New features to boost your workflow:
|
Since 93644d5 the TryCatch guarding StringBytes::Encode in the completion callbacks of mkdtemp, realpath.native, readlink, recursive mkdir, recursive readdir and dir.read is still active when the JS callback runs. Exceptions thrown by the callback, or by the nextTick queue drained after it, are caught by it and never reported. Leave the TryCatch before calling into JS. Fixes: nodejs#65667 Refs: nodejs#57706 Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
marcopiraccini
force-pushed
the
fs-trycatch-scope
branch
from
September 26, 2026 11:56
57b5139 to
84f74ce
Compare
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.
Since #57706 the completion callbacks of
fs.mkdtemp,fs.realpath.native,fs.readlink,fs.mkdir({ recursive }),fs.readdir({ recursive })anddir.read()call into JS while theTryCatchmeant forStringBytes::Encodeis still in scope.Any exception thrown by the user callback, or by the
nextTickqueue drained right after it (e.g. afterawait fsp.mkdtemp()), is swallowed: the process prints nothing and exits 0, anduncaughtExceptionnever fires. v22 is not affected.This moves the
TryCatchinto a small helper that produces the value first and callsResolve()/Reject()only after leaving it.Fixes: #65667
NOTE:
make lint-jscurrently fails until #66307 lands