Skip to content

Commit 7d4a207

Browse files
committed
win: fix fs.promises.realpath for long paths
Unlike other fs functions that work with paths, realpath isn't using pathModule.toNamespacedPath prior to calling libuv function. This is causing issues on windows. Windows long path test is also improved to cover the mentioned issue. Fixes: #51031
1 parent 23031d9 commit 7d4a207

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/internal/fs/promises.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ async function realpath(path, options) {
11601160
options = getOptions(options);
11611161
path = getValidatedPath(path);
11621162
return await PromisePrototypeThen(
1163-
binding.realpath(path, options.encoding, kUsePromises),
1163+
binding.realpath(pathModule.toNamespacedPath(path), options.encoding, kUsePromises),
11641164
undefined,
11651165
handleErrorFromBinding,
11661166
);

test/parallel/test-fs-long-path.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ fs.writeFile(fullPath, 'ok', common.mustSucceed(() => {
4646

4747
// Tests https://github.com/nodejs/node/issues/39721
4848
fs.realpath.native(fullPath, common.mustSucceed());
49+
50+
// Tests https://github.com/nodejs/node/issues/51031
51+
fs.promises.realpath(fullPath).then(common.mustCall(), common.mustNotCall());
4952
}));

0 commit comments

Comments
 (0)