Open
Description
Version
v24.2.0
Platform
Linux 5d31fb693130 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
fs
What steps will reproduce the bug?
Make directories and files like this:
- (rootDir)
- permissionNotGranted (Owner: root:root / Perm: 700)
- a.txt (Owner: root:root / Perm: 700)
- b.txt (Owner: root:root / Perm: 700)
- permissionGranted (Owner: vscode:vscode / Perm: 755)
- c.txt (Owner: vscode:vscode / Perm: 755)
- d.txt (Owner: vscode:vscode / Perm: 755)
And run following script with user vscode
, throws TypeError: Cannot read properties of null (reading 'length')
import fs from "fs";
import fsAsync from "fs/promises";
// This is callback version
const result = 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)
Logs and StackTrace(Sync Version) -- It is OK.
Matches: [
'gh-issue-58670.js',
'permissionGranted',
'permissionNotGranted',
'permissionGranted/c.txt',
'permissionGranted/d.txt'
]
Logs and StackTrace(Async Version)
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
Metadata
Metadata
Assignees
Labels
No labels