-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
fix(fs): prevent ENOENT on subst drive root paths like "M:\\" on Windows #58989
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #58989 +/- ##
==========================================
- Coverage 90.14% 90.05% -0.09%
==========================================
Files 630 645 +15
Lines 186784 189130 +2346
Branches 36653 37089 +436
==========================================
+ Hits 168377 170327 +1950
- Misses 11205 11511 +306
- Partials 7202 7292 +90
🚀 New features to boost your workflow:
|
1474ed1
to
fcaee03
Compare
I've force-pushed a fix (e.g. lint issue resolved). |
When using fs.readdir() or fs.readdirSync() on subst drive root paths such as M:\, Node.js was incorrectly adding a second backslash, resulting in M:\\, which caused ENOENT errors on Windows. This patch adds a safeguard to avoid appending a backslash if the path already represents a drive root, including both standard (e.g. C:\) and namespaced (e.g. \\?\C:\) formats. Fixes: nodejs#58970
fcaee03
to
c97462b
Compare
I apologize - the format-cpp check failed again. I've pushed another fix to address the formatting issue. This appears to be an unrelated test, as:
|
Failed to start CI⚠ No approving reviews found ✘ Refusing to run CI on potentially unsafe PRhttps://github.com/nodejs/node/actions/runs/16441290676 |
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.
Approving to enable starting the CI. Still not approved to land AFAIC.
This PR fixes an issue where
fs.readdirSync('M:\\')
and related calls would fail with anENOENT
error on Windows when using subst drive roots.Previously, Node.js added a trailing backslash (
\
) even when the input path was already a drive root (e.g.,M:\
or\\?\M:\
), resulting in invalid paths likeM:\\\
. This patch introduces a check to detect standard and namespaced drive root formats and avoid appending an extra slash in those cases.The fix is Windows-specific and scoped only to the logic within
fs.readdir
.Changes
src/node_file.cc
to detect and skip appending\
for drive root pathstest/parallel/test-fs-readdir-windows-subst.js
subst
-like paths with and without trailing slashesENOENT
error is thrown for valid drive rootsContext
Fixes: #58970