Skip to content

fs/promises.glob breaks on symlinks, unlike fs.globSync #58276

Open
@ChALkeR

Description

@ChALkeR

Version

v24.0.1

Platform

Darwin macbook-air.taile5a6b.ts.net 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:34:14 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T8122 arm64

Subsystem

fs

What steps will reproduce the bug?

touch a.txt
ln -s a.txt b.txt
node -e "console.log(require('fs').globSync('**/*.txt'))" // ok
node -e "Array.fromAsync(require('fs/promises').glob('**/*.txt'))" // fail

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

Always

What is the expected behavior? Why is that the expected behavior?

It should work and return those entries like globSync

What do you see instead?

TypeError: Cannot read properties of null (reading 'length')
    at #iterateSubpatterns (node:internal/fs/glob:627:34)
    at async Glob.glob (node:internal/fs/glob:540:9)
    at async Object.glob (node:internal/fs/promises:1266:3)

Additional information

See:

children = await this.#cache.readdir(fullpath);
}
for (let i = 0; i < children.length; i++) {

async readdir(path) {
const cached = this.#readdirCache.get(path);
if (cached) {
return cached;
}
const promise = PromisePrototypeThen(readdir(path, { __proto__: null, withFileTypes: true }), null, () => null);
this.#readdirCache.set(path, promise);
return promise;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions