Skip to content

fs: fix glob early return skipping sibling entries - #64895

Open
webdevelopersrinu wants to merge 1 commit into
nodejs:mainfrom
webdevelopersrinu:fix-glob-sibling-skip
Open

fs: fix glob early return skipping sibling entries#64895
webdevelopersrinu wants to merge 1 commit into
nodejs:mainfrom
webdevelopersrinu:fix-glob-sibling-skip

Conversation

@webdevelopersrinu

Copy link
Copy Markdown

The children loop in the glob traversal returned from the whole method when a
child path had already been seen through a different pattern context, silently
dropping the remaining sibling entries. Whether this triggered depended on
directory iteration order, which also made test-fs-glob.mjs flaky.

This removes the check — the cache.add call at the start of the traversal
already prevents reprocessing. Deno, which ports this implementation, fixed
the same bug.

The regression test pins the directory iteration order that triggers the bug,
so it fails deterministically without the fix (verified: without the fix,
a/b, a/x, a/z are missing from the results for pattern a/**/../*,
in both the sync and async implementations).

Supersedes #62901 — the author there agreed to hand over the work
(#62901 (comment)).

Fixes: #62897

The children loop in the glob traversal returned from the whole method
when a child path had already been seen through a different pattern
context, silently dropping the remaining sibling entries. Whether this
triggered depended on directory iteration order, which also made
test-fs-glob.mjs flaky.

Remove the check: the cache.add call at the start of the traversal
already prevents reprocessing.

Fixes: nodejs#62897
Co-authored-by: semimikoh <ejffjeosms@gmail.com>
@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Aug 1, 2026
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. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs.glob: return in cache-seen check aborts sibling processing, makes test-fs-glob.mjs flaky

3 participants