You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs.promises.realpath errors with long paths (fs.realpath.native does not error) #51031
Save the following script in a path that has more than 10 characters (e.g. C:\\abcdefghi).
Then, run it.
import{resolve}from'node:path'import{realpath,writeFile}from'node:fs/promises'import{realpathasrealpathCallback,realpathSync}from'node:fs'constp=`./test_${'a'.repeat(240)}.txt`awaitwriteFile(p,'')console.log('length: ',resolve(p).length)try{awaitrealpath(p)}catch(e){console.log('error with fs.promises.realpath',e)}try{awaitnewPromise((res,rej)=>{realpathCallback(p,(err,resolved)=>{if(err){rej(err)return}res(resolved)})})}catch(e){console.log('error with fs.realpath',e)}try{awaitnewPromise((res,rej)=>{realpathCallback.native(p,(err,resolved)=>{if(err){rej(err)return}res(resolved)})})}catch(e){console.log('error with fs.realpath.native',e)}try{realpathSync(p)}catch(e){console.log('error with fs.realpathSync',e)}try{realpathSync.native(p)}catch(e){console.log('error with fs.realpathSync.native',e)}
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
No error happens.
What do you see instead?
The following error happens:
error with fs.promises.realpath [Error: ENOENT: no such file or directory, realpath './test_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.txt']
Additional information
Maybe related to #50753, but running (Get-Item -Path "Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem").GetValue("LongPathsEnabled") (in both normal mode and admin mode) returns 0 on my machine.
Activity
sapphi-red commentedon Dec 3, 2023
node/lib/fs.js
Lines 2931 to 2938 in 23031d9
node/lib/internal/fs/promises.js
Lines 1159 to 1167 in 23031d9
It seems
pathModule.toNamespacedPathis missing forfs.promises, will make a PR.fs: fix fs.promises.realpath for long paths on Windows
fs: fix fs.promises.realpath for long paths on Windows
fix:use fs.realpath.native instead of fs.promises.realpath to fix lon…