vfs: answer for unowned paths under reserved root · nodejs/node@7cdf5f0 · GitHub
Skip to content

Commit 7cdf5f0

Browse files
pipobscureaduh95
authored andcommitted
vfs: answer for unowned paths under reserved root
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: #65748 Signed-off-by: Philipp Dunkel <pip@pipobscure.com> PR-URL: #65814 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 48158fb commit 7cdf5f0

2 files changed

Lines changed: 133 additions & 36 deletions

File tree

‎lib/internal/vfs/setup.js‎

Lines changed: 74 additions & 36 deletions
Lines changed: 59 additions & 0 deletions

0 commit comments

Comments
 (0)