Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.promises.realpath throws ENOENT on long paths on Windows, while the realpathSync version works for the same paths #39721

Closed
radeusgd opened this issue Aug 9, 2021 · 1 comment · Fixed by #44536
Labels
fs Issues and PRs related to the fs subsystem / file system.

Comments

@radeusgd
Copy link

radeusgd commented Aug 9, 2021

Version

v14.17.3

Platform

Microsoft Windows NT 10.0.18363.0 x64

Subsystem

No response

What steps will reproduce the bug?

Run the following script:

const fs = require("fs");

var path = ".";
for (var i = 0; i < 40; ++i) {
   path += "\\foobar";
   fs.mkdirSync(path);
}

console.log("These two work and yield a valid result:");
console.log(fs.realpathSync(path));
fs.realpath(path, function(err, res) { console.log(err, res); });


console.log("But this one throws ENOENT:");
async function repro() {
   const res = await fs.promises.realpath(path);
   console.log(res);
}

repro();

As described in the code, the first two examples will work correctly, printing the expected results, but the third one (repro) will throw.

How often does it reproduce? Is there a required condition?

It seems to always work, but only on Windows.

What is the expected behavior?

The promise-based variant of realpath should correctly resolve the path, in the same way as the synchronous and callback-based ones.

What do you see instead?

(node:3084) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, realpath '.\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar\foobar'

Additional information

No response

@targos targos added the fs Issues and PRs related to the fs subsystem / file system. label Aug 9, 2021
@privatenumber
Copy link
Contributor

fsPromises.realpath(path[, options]) actually works the same way as realpath.native rather than realpath:

Determines the actual location of path using the same semantics as the fs.realpath.native() function.

You might want to request a promise version of non-native realpath, and promisify it for the time-being.

StefanStojanovic added a commit to JaneaSystems/node that referenced this issue Sep 5, 2022
Libuv has a manifest file to enable working with long paths. Node does
not have that in its manifest and that leads to problems in some cases
on Windows (eg. realpath.native).

Windows long path test is also improved to cover the mentioned issue.

Fixes: nodejs#39721
StefanStojanovic added a commit to JaneaSystems/node that referenced this issue Sep 6, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: nodejs#39721
nodejs-github-bot pushed a commit that referenced this issue Sep 13, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Fyko pushed a commit to Fyko/node that referenced this issue Sep 15, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: nodejs#39721
PR-URL: nodejs#44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
RafaelGSS pushed a commit that referenced this issue Sep 26, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
RafaelGSS pushed a commit that referenced this issue Sep 26, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
RafaelGSS pushed a commit that referenced this issue Sep 26, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
juanarbol pushed a commit that referenced this issue Oct 4, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
juanarbol pushed a commit that referenced this issue Oct 4, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
juanarbol pushed a commit that referenced this issue Oct 4, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
juanarbol pushed a commit that referenced this issue Oct 7, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
juanarbol pushed a commit that referenced this issue Oct 10, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
juanarbol pushed a commit that referenced this issue Oct 11, 2022
Unlike other fs.js functions that work with paths, realpath.native 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: #39721
PR-URL: #44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
guangwong pushed a commit to noslate-project/node that referenced this issue Jan 3, 2023
Unlike other fs.js functions that work with paths, realpath.native 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: nodejs/node#39721
PR-URL: nodejs/node#44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
guangwong pushed a commit to noslate-project/node that referenced this issue Jan 3, 2023
Unlike other fs.js functions that work with paths, realpath.native 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: nodejs/node#39721
PR-URL: nodejs/node#44536
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
3 participants