Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f823041

Browse files
sapphi-redrichardlau
authored andcommittedMar 25, 2024
fs: fix fs.promises.realpath for long paths on Windows
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 PR-URL: #51032 Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 9474ff4 commit f823041

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎lib/internal/fs/promises.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ async function lutimes(path, atime, mtime) {
10101010
async function realpath(path, options) {
10111011
options = getOptions(options);
10121012
path = getValidatedPath(path);
1013-
return binding.realpath(path, options.encoding, kUsePromises);
1013+
return binding.realpath(pathModule.toNamespacedPath(path), options.encoding, kUsePromises);
10141014
}
10151015

10161016
async function mkdtemp(prefix, options) {

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

+3
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)
Please sign in to comment.