vfs: answer for unowned paths under reserved root - #65814
Open
pipobscure wants to merge 1 commit into
Open
Conversation
The module loader manufactures paths under the reserved VFS root that no layer owns: resolving a mount point as a directory first probes the sibling names `<mount>.js`, `<mount>.json` and `<mount>.node`, and a package.json walk-up passes the parents of the mount point. The lookup declined those because their layer segment is not a plain id, so they fell through to the native loader and the real file system. On POSIX that is harmless (ENOTDIR under /dev/null), but on Windows the root sits under `\\.\nul`, and `\\.\nul\<anything>` opens the NUL device: libuv reports it as a character device and a read returns nothing. The loader therefore picked `\\.\nul\vfs\<id>.js` as an existing file, and the native walk-up above it then read the device as an empty package.json and failed with ERR_INVALID_PACKAGE_CONFIG for `\\.\nul\package.json`. Any require() of a mount point hits this on Windows. Distinguish "under the root but unowned" from "outside the root" in the lookup and have every loader override report the former as not found: stat gives ENOENT, reads and realpath throw ENOENT, the package.json lookups return their "no package.json" results, and upward walks stop at the reserved root. Paths outside the root still go to the native loader as before. Refs: nodejs#65748 Signed-off-by: Philipp Dunkel <[email protected]>
pipobscure
force-pushed
the
vfs-reserved-root-lookup
branch
from
September 5, 2026 14:43
e1c6827 to
fc612c8
Compare
Member
|
let’s see what CI thinks |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65814 +/- ##
==========================================
- Coverage 90.19% 90.18% -0.01%
==========================================
Files 770 770
Lines 264410 264448 +38
Branches 50243 50248 +5
==========================================
+ Hits 238479 238491 +12
- Misses 16926 16974 +48
+ Partials 9005 8983 -22
🚀 New features to boost your workflow:
|
Collaborator
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.
The module loader manufactures paths under the reserved VFS root that no layer owns: resolving a mount point as a directory first probes the sibling names
<mount>.js,<mount>.jsonand<mount>.node, and a package.json walk-up passes the parents of the mount point. The lookup declined those because their layer segment is not a plain id, so they fell through to the native loader and the real file system.On POSIX that is harmless (ENOTDIR under /dev/null), but on Windows the root sits under
\\.\nul, and\\.\nul\<anything>opens the NUL device: libuv reports it as a character device and a read returns nothing. The loader therefore picked\\.\nul\vfs\<id>.jsas an existing file, and the native walk-up above it then read the device as an empty package.json and failed with ERR_INVALID_PACKAGE_CONFIG for\\.\nul\package.json. Any require() of a mount point hits this on Windows.Distinguish "under the root but unowned" from "outside the root" in the lookup and have every loader override report the former as not found: stat gives ENOENT, reads and realpath throw ENOENT, the package.json lookups return their "no package.json" results, and upward walks stop at the reserved root. Paths outside the root still go to the native loader as before.
NOTE: This was only validated agains a pretty bad Windows VM on my end. So if someone that has access to a better Windows environment could double check this work, I'd appreciate it.