vfs: add minimal node:vfs subsystem#63115
Conversation
|
Review requested:
|
The docs in this PR claim that you can call |
30f5755 to
779fc37
Compare
Fixed, good spot. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #63115 +/- ##
==========================================
+ Coverage 90.14% 90.31% +0.16%
==========================================
Files 718 730 +12
Lines 227984 233756 +5772
Branches 42835 43803 +968
==========================================
+ Hits 205522 211121 +5599
- Misses 14235 14400 +165
- Partials 8227 8235 +8
🚀 New features to boost your workflow:
|
|
Can you add a test for #63158? |
The first block used persistent: false plus setTimeout to trigger the write. The watcher's poll timer was unref'd, so on slow runners the write timer could fire before the first poll and the change event would be missed. Use the same await-once pattern as the other blocks in the file with a content-length change so the size-based stat-change detector always fires. Assisted-by: Claude-Opus4.7 Signed-off-by: Matteo Collina <hello@matteocollina.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Mirrors the recently-merged handling for node:ffi (see nodejs#63158): when --experimental-vfs is not set, node:vfs is filtered out of the public Module.builtinModules list. Adds matching coverage in test-vfs-flag. Refs: nodejs#63158 Assisted-by: Claude-Opus4.7 Signed-off-by: Matteo Collina <hello@matteocollina.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
The getter exposed the raw real-fs file descriptor of a virtual file handle, which is a leaky abstraction: it lets user code bypass the VFS layer. The only consumer was a test that closed the real fd to trigger the EBADF rejection paths in the async fd ops; those branches are defensive and unreachable from the public API, so the test block is dropped along with the getter. Assisted-by: Claude-Opus4.7 Signed-off-by: Matteo Collina <hello@matteocollina.com>
* file_handle: import SymbolDispose from primordials so the SymbolDispose prototype binding doesn't throw at load time. * providers/real: import getValidatedPath and setOwnProperty that the code-review rewrite of the rootPath validator referenced without importing. * test-vfs-real-provider: getValidatedPath rejects non-strings with ERR_INVALID_ARG_TYPE (not ERR_INVALID_ARG_VALUE) and now accepts the empty string, so the assertions are updated and the empty-string case dropped. * test-vfs-memory-provider-dynamic: the object-literal rewrite left a stray ');' instead of '}', which crashed the parser. Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Tracks the suggestion from review to delegate the async fd ops in RealFileHandle to FileHandle methods instead of manually wrapping fs.read/write/fstat/ftruncate/close in Promises. The refactor is blocked on a way to wrap an existing numeric fd in a FileHandle so a sync-opened handle can share one underlying handle for async ops. Signed-off-by: Matteo Collina <hello@matteocollina.com>
RealFSProvider.realpath fed the resolved path through StringPrototype startsWith against the stored rootPath plus a separator. On Windows fs.realpathSync is a JS implementation that preserves case while fs.promises.realpath calls the native binding, which canonicalizes the drive letter (and potentially other components). The async path then fails the startsWith check and rejects with EACCES, even for valid paths inside the root. Use path.relative to test containment instead, which treats the comparison as case-insensitive on Windows. Both realpathSync and realpath now share the same helper. Fixes failure in test-vfs-real-provider-symlinks on test-binary-windows-js-suites. Signed-off-by: Matteo Collina <hello@matteocollina.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> Co-authored-by: Matteo Collina <matteo.collina@gmail.com>
* test-vfs-stream-errors: drop the unused `assert` import. * test-vfs-streams: capitalize a lowercase comment to satisfy capitalized-comments. Signed-off-by: Matteo Collina <hello@matteocollina.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
spawnSyncAndAssert handles the expected stderr/status, so the top-level `assert` is no longer referenced. Signed-off-by: Matteo Collina <hello@matteocollina.com>
The currentPath segment used for symlink resolution and for the #ensurePopulated call below was being computed twice in the loop body. Compute it once at the top of the iteration and reuse it in both branches. Signed-off-by: Matteo Collina <hello@matteocollina.com>
|
Landed in c9562dd |
Adds an experimental
node:vfsbuiltin (gated behind--experimental-vfs) withVirtualFileSystem,VirtualProvider,MemoryProvider, andRealFSProvider. No integration withnode:fs, the module loader, or SEA those are intended to land in follow-up PRs.Extracted from: #61478
Approximate line counts: code ~4k / docs ~1k / tests ~5k — total ~10k lines, with tests being the largest share.