Skip to content

Commit

Permalink
win: fix fs.promises.realpath for long paths
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sapphi-red committed Dec 3, 2023
1 parent 23031d9 commit 6b4a8d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ async function realpath(path, options) {
options = getOptions(options);
path = getValidatedPath(path);
return await PromisePrototypeThen(
binding.realpath(path, options.encoding, kUsePromises),
binding.realpath(pathModule.toNamespacedPath(path), options.encoding, kUsePromises),
undefined,
handleErrorFromBinding,
);
Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-fs-long-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ fs.writeFile(fullPath, 'ok', common.mustSucceed(() => {

// Tests https://github.com/nodejs/node/issues/39721
fs.realpath.native(fullPath, common.mustSucceed());

// Tests https://github.com/nodejs/node/issues/51031
fs.promises.realpath(fullPath).then(common.mustCall(), common.mustNotCall());
}));

0 comments on commit 6b4a8d5

Please sign in to comment.