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.glob and fs/promises.glob breaks when read directory that permission is not granted #58670
And run following script with user vscode, throws TypeError: Cannot read properties of null (reading 'length')
importfsfrom"fs";importfsAsyncfrom"fs/promises";// This is callback versionconstresult=fs.glob("**/*",(err,matches)=>{if(err){console.error("Error:",err);return;}console.log("Matches:",matches);});// This is sync version// const result = fs.globSync("**/*");// console.log("Matches:", result);// This is async version// const result = fsAsync.glob("**/*");// for await (const file of result) {// console.log(file);// }
How often does it reproduce? Is there a required condition?
How often: Always.
It is reproducible when read directory that permission is not granted on glob.
What is the expected behavior? Why is that the expected behavior?
Like fs.globSync, calling fs.glob should be successful, and listing permissionNotGranted directory, and ignoring reading into permissionNotGranted directory.
What do you see instead?
Logs and StackTrace(Callback Version)
Error: TypeError: Cannot read properties of null (reading 'length')
at #iterateSubpatterns (node:internal/fs/glob:628:34)
at async Glob.glob (node:internal/fs/glob:541:9)
permissionGranted
permissionNotGranted
node:internal/fs/glob:628
for (let i = 0; i < children.length; i++) {
^
TypeError: Cannot read properties of null (reading 'length')
at #iterateSubpatterns (node:internal/fs/glob:628:34)
at async Glob.glob (node:internal/fs/glob:541:9)
at async Object.glob (node:internal/fs/promises:1271:3)
at async file:///workspaces/nodejs-sandbox/gh-issue-58670.js:17:18
Node.js v24.2.0
Additional information
Throwing error occurs on same lines of below: #58276
Activity
fs: fix glob TypeError on restricted dirs
fs: fix glob TypeError on restricted dirs
fs: fix glob TypeError on restricted dirs
fs: fix glob TypeError on restricted dirs
fs: fix glob TypeError on restricted dirs
fs: fix glob TypeError on restricted dirs
fs: fix glob TypeError on restricted dirs