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 91.94% 90.24% -1.70%
==========================================
Files 362 726 +364
Lines 155999 231715 +75716
Branches 24057 43706 +19649
==========================================
+ Hits 143429 209113 +65684
- Misses 12295 14388 +2093
- Partials 275 8214 +7939
🚀 New features to boost your workflow:
|
|
Can you add a test for #63158? |
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>
| let data = ''; | ||
|
|
||
| stream.on('open', common.mustCall((fd) => { | ||
| assert.ok((fd & 0x40000000) !== 0); |
There was a problem hiding this comment.
| assert.ok((fd & 0x40000000) !== 0); | |
| assert.notStrictEqual(fd & 0x40000000, 0); |
| ws.on('error', common.mustCall((err) => { | ||
| assert.ok(err); | ||
| })); |
There was a problem hiding this comment.
| ws.on('error', common.mustCall((err) => { | |
| assert.ok(err); | |
| })); | |
| ws.on('error', common.expectsError()); |
| ws.on('error', common.mustCall((err) => { | ||
| assert.ok(err); | ||
| })); |
There was a problem hiding this comment.
| ws.on('error', common.mustCall((err) => { | |
| assert.ok(err); | |
| })); | |
| ws.on('error', common.expectsError()); |
| const fd = myVfs.openSync('/cl.txt'); | ||
| const rs = myVfs.createReadStream('/cl.txt', { fd, autoClose: true }); | ||
| myVfs.closeSync(fd); | ||
| rs.on('error', common.mustCall()); |
There was a problem hiding this comment.
| rs.on('error', common.mustCall()); | |
| rs.on('error', common.expectsError()); |
| rs.on('error', common.mustCall((err) => { | ||
| assert.strictEqual(err.code, 'EBADF'); | ||
| })); |
There was a problem hiding this comment.
| rs.on('error', common.mustCall((err) => { | |
| assert.strictEqual(err.code, 'EBADF'); | |
| })); | |
| rs.on('error', common.expectsError({ | |
| code: 'EBADF', | |
| })); |
| stream.on('error', common.mustCall((err) => { | ||
| assert.strictEqual(err.code, 'ENOENT'); | ||
| })); |
There was a problem hiding this comment.
| stream.on('error', common.mustCall((err) => { | |
| assert.strictEqual(err.code, 'ENOENT'); | |
| })); | |
| stream.on('error', common.expectsError({ | |
| code: 'ENOENT', | |
| })); |
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>
Qard
left a comment
There was a problem hiding this comment.
LGTM. Some minor improvements which could be made, but nothing which needs to block landing. 🙂
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>
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.