fs: fix realpath of namespaced drive paths · nodejs/node@bc1e19b · GitHub
Skip to content

Commit bc1e19b

Browse files
jazellyaduh95
authored andcommitted
fs: fix realpath of namespaced drive paths
The JavaScript realpath implementation probes a namespaced drive root through the fs binding. Windows path resolution drops the trailing separator from that probe, so lstat receives C: and reports EISDIR. Use the regular drive-root spelling only for the probe. Preserve the namespaced spelling for traversal and returned paths. Signed-off-by: Jason Zhang <xzha4350@gmail.com> PR-URL: #65378 Fixes: #62446 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
1 parent f644853 commit bc1e19b

3 files changed

Lines changed: 97 additions & 4 deletions

File tree

lib/fs.js

Lines changed: 16 additions & 4 deletions

test/es-module/test-esm-long-path-win.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ describe('long path on Windows', () => {
4747
tmpdir.refresh();
4848
});
4949

50+
it('runs an extended-length path as the entry point', async () => {
51+
// The module loader resolves argv[1] through the JavaScript realpath
52+
// implementation before executing it.
53+
tmpdir.refresh();
54+
const entry = tmpdir.resolve('extended-entry.js');
55+
fs.writeFileSync(entry, 'console.log("hello world");');
56+
57+
const { code, signal, stderr, stdout } = await spawnPromisified(
58+
execPath,
59+
[path.toNamespacedPath(entry)],
60+
);
61+
62+
assert.strictEqual(stderr, '');
63+
assert.strictEqual(stdout.trim(), 'hello world');
64+
assert.strictEqual(code, 0);
65+
assert.strictEqual(signal, null);
66+
});
67+
5068
it('check long path in LegacyMainResolve - 1', () => {
5169
// Module layout will be the following:
5270
// package.json
Lines changed: 63 additions & 0 deletions

0 commit comments

Comments
 (0)