René's URL Explorer Experiment


Title: `fs.glob`: return in cache-seen check aborts sibling processing, makes `test-fs-glob.mjs` flaky · Issue #62897 · nodejs/node · GitHub

Open Graph Title: `fs.glob`: return in cache-seen check aborts sibling processing, makes `test-fs-glob.mjs` flaky · Issue #62897 · nodejs/node

X Title: `fs.glob`: return in cache-seen check aborts sibling processing, makes `test-fs-glob.mjs` flaky · Issue #62897 · nodejs/node

Description: Version Reproduced on Node.js v25.x (current main), present since the glob implementation was added. Platform Linux (ext4/tmpfs) -- most reproducible there due to non-deterministic readdir ordering, but the bug exists on all platforms. S...

Open Graph Description: Version Reproduced on Node.js v25.x (current main), present since the glob implementation was added. Platform Linux (ext4/tmpfs) -- most reproducible there due to non-deterministic readdir ordering...

X Description: Version Reproduced on Node.js v25.x (current main), present since the glob implementation was added. Platform Linux (ext4/tmpfs) -- most reproducible there due to non-deterministic readdir ordering...

Opengraph URL: https://github.com/nodejs/node/issues/62897

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`fs.glob`: return in cache-seen check aborts sibling processing, makes `test-fs-glob.mjs` flaky","articleBody":"### Version\n\nReproduced on Node.js v25.x (current main), present since the glob implementation was added.\n\n### Platform\n\n```text\nLinux (ext4/tmpfs) -- most reproducible there due to non-deterministic readdir ordering, but the bug exists on all platforms.\n```\n\n### Subsystem\n\nfs\n\n### What steps will reproduce the bug?\n\nThe bug is in lib/internal/fs/glob.js, in both #addSubpatterns and #iterateSubpatterns. The cache.seen check inside the children iteration loop uses return, which exits the entire method instead of skipping just the current child:\n\n```js\nfor (let i = 0; i \u003c children.length; i++) {\n  // ...\n  for (const index of pattern.indexes) {\n    if (this.#cache.seen(entryPath, pattern, index) || this.#cache.seen(entryPath, pattern, index + 1)) {\n      return; // \u003c-- exits the entire method, skipping ALL remaining children\n    }\n```\n\nThis can be triggered with **/../* patterns. Minimal reproduction:\n\n```js\nconst { mkdirSync, mkdtempSync, writeFileSync, globSync, rmSync } = require('fs');\nconst { tmpdir } = require('os');\nconst { join } = require('path');\n\nconst tmp = mkdtempSync(join(tmpdir(), 'glob-bug-'));\n\n// a/b/c/d  (nested dirs)\n// a/c/d/c/ (child \"c\" of a/c/d triggers \"..\" back to a/c, creating a duplicate queue entry)\n// a/x      (file)\n// a/z      (file)\nconst a = join(tmp, 'a');\nmkdirSync(join(a, 'b', 'c', 'd'), { recursive: true });\nmkdirSync(join(a, 'c', 'd', 'c'), { recursive: true });\nwriteFileSync(join(a, 'x'), '');\nwriteFileSync(join(a, 'z'), '');\n\n// Run many times -- result varies depending on readdir ordering\nfor (let i = 0; i \u003c 100; i++) {\n  const results = globSync('a/**/../*', { cwd: tmp }).sort();\n  for (const expected of ['a/b', 'a/c', 'a/x', 'a/z']) {\n    if (!results.includes(expected)) {\n      console.error(`Iteration ${i}: missing \"${expected}\" from results:`, results);\n      process.exit(1);\n    }\n  }\n}\nconsole.log('ok');\n\nrmSync(tmp, { recursive: true, force: true });\n```\nOn Linux with ext4/tmpfs, this frequently fails with a/c or other entries missing. On macOS (APFS), readdir ordering is more stable so it may require more iterations or a different directory structure.\n\n### How often does it reproduce? Is there a required condition?\n\nDepends on readdir ordering, which varies by filesystem. On Linux CI (ext4/tmpfs) it reproduces frequently. The required condition is a directory tree deep enough that the .. handler in the GLOBSTAR branch queues a path that was already queued by a parent directory's processing.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`globSync('a/**/../*', { cwd })` should return all entries reachable via `**/../*` regardless of readdir ordering. The `cache.seen` check should skip only the already-processed child, not abort processing of all remaining siblings.\n\n### What do you see instead?\n\nDepending on readdir ordering, some entries in the parent directory are missing from the results. The `test-fs-glob.mjs` test case for `a/!(symlink)/**/../*` is affected -- a/c and a/symlink can be missing.\n\n### Additional information\n\nI discovered this in Deno, due to flakiness when running `test-fs-glob.mjs`.\n\n### Root cause\n\nWhen a pattern contains `**/../*`:\n\n1. Processing directory `a/c` with GLOBSTAR queues three items via the `..` handler and #addSubpattern: `a/c` with `{*}`, `a` with `{*}`, and `a/c/d` with `{**}`\n2. The queue is LIFO (ArrayPrototypePop), so `a/c/d` is popped first. Its child `c` (directory) triggers the `..` handler again, which adds `a/c` with `{*}` to subpatterns a second time\n3. This second `a/c {*} ` gets pushed onto the queue after a `{*}`, so LIFO pops it before a `{*}`\n4. `a/c {*} ` is processed, adding `*` to `cache[\"a/c\"]`\n5. When a `{*}` is finally processed and iterates children of `a/`, child `c` has `entryPath = \"a/c\"` which is now in the cache. `cache.seen` returns true and return exits the method, skipping all remaining siblings (e.g., `a/x`, `a/z`, `a/symlink`)\n\nWhich siblings are skipped depends on readdir ordering, hence the flakiness.\n\n### Suggested fix\n\nRemove the cache.seen check from the children iteration loop entirely:\n\n```diff\n-      for (const index of pattern.indexes) {\n-        if (this.#cache.seen(entryPath, pattern, index) || this.#cache.seen(entryPath, pattern, index + 1)) {\n-          return;\n-        }\n+      for (const index of pattern.indexes) {\n```\n\nThe cache.add call at the top of #addSubpatterns/#iterateSubpatterns already prevents reprocessing and infinite recursion.\nThe children-level check is a redundant optimization that incorrectly prevents entries from being added to results when they\nwere previously traversed from a different context (e.g., a/b was recursed into via its own queue entry, but still needs to\nappear as a result when the parent a matches * against its children).\n\nThis needs to be applied in both #addSubpatterns (sync) and #iterateSubpatterns (async).\n\nFix PR in Deno: https://github.com/denoland/deno/issues/33372\n\nI used AI to generate this report and the fix in Deno.","author":{"url":"https://github.com/bartlomieju","@type":"Person","name":"bartlomieju"},"datePublished":"2026-04-22T19:50:37Z","url":"https://github.com/nodejs/node/issues/62897"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:da500608-2b9c-843c-9ff6-fe13ccad5e34
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id91F4:21A83E:58AF82:72FD76:6AED29A2
html-safe-nonce3bf7e72118d73962d65ec94f149c4e75b5204f9a3701a58eda3a983e4f927aa4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MUY0OjIxQTgzRTo1OEFGODI6NzJGRDc2OjZBRUQyOUEyIiwidmlzaXRvcl9pZCI6IjI2NDQ4Mzk5MDkxODc5ODc4NzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacfac4f4585e25875ecc4aec9596de1409c67ff207ae4bfda29413c4a51cb028cb
hovercard-subject-tagissue:4311486665
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/62897/issue_layout
twitter:imagehttps://opengraph.githubassets.com/26135af49c5c518324c19766a2da01cf1341fa0680f9c85d1f1334109e00ccb3/nodejs/node/issues/62897
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/26135af49c5c518324c19766a2da01cf1341fa0680f9c85d1f1334109e00ccb3/nodejs/node/issues/62897
og:image:altVersion Reproduced on Node.js v25.x (current main), present since the glob implementation was added. Platform Linux (ext4/tmpfs) -- most reproducible there due to non-deterministic readdir ordering...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebartlomieju
hostnamegithub.com
expected-hostnamegithub.com
None9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release98b41fa4b5635ceb45a4c54320fced73817ff290
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/62897#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F62897
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F62897
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/62897
Reloadhttps://github.com/nodejs/node/issues/62897
Reloadhttps://github.com/nodejs/node/issues/62897
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests666 (666)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/62897
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/62897
#64895https://github.com/nodejs/node/pull/64895
fs.glob: return in cache-seen check aborts sibling processing, makes test-fs-glob.mjs flakyhttps://github.com/nodejs/node/issues/62897#top
#64895https://github.com/nodejs/node/pull/64895
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
fsIssues and PRs related to file-system APIs and the fs module.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fs%22
https://github.com/bartlomieju
bartlomiejuhttps://github.com/bartlomieju
on Apr 22, 2026https://github.com/nodejs/node/issues/62897#issue-4311486665
denoland/deno#33372https://github.com/denoland/deno/pull/33372
Renegade334https://github.com/Renegade334
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
fsIssues and PRs related to file-system APIs and the fs module.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fs%22
on Apr 22, 2026https://github.com/nodejs/node/issues/62897#event-24770197303
https://github.com/truffle-dev
truffle-devhttps://github.com/truffle-dev
on Apr 23, 2026https://github.com/nodejs/node/issues/62897#issuecomment-4300949964
lib/internal/fs/glob.js:438-440https://github.com/nodejs/node/blob/acb1bd7107b8c1f26cfb4dd41e2a0cebd64bbfb0/lib/internal/fs/glob.js#L438-L440
lib/internal/fs/glob.js:648-650https://github.com/nodejs/node/blob/acb1bd7107b8c1f26cfb4dd41e2a0cebd64bbfb0/lib/internal/fs/glob.js#L648-L650
glob.js:358-362https://github.com/nodejs/node/blob/acb1bd7107b8c1f26cfb4dd41e2a0cebd64bbfb0/lib/internal/fs/glob.js#L358-L362
glob.js:559-563https://github.com/nodejs/node/blob/acb1bd7107b8c1f26cfb4dd41e2a0cebd64bbfb0/lib/internal/fs/glob.js#L559-L563
https://github.com/bartlomieju
bartlomiejuhttps://github.com/bartlomieju
on Apr 23, 2026https://github.com/nodejs/node/issues/62897#issuecomment-4303043822
@truffle-devhttps://github.com/truffle-dev
#62901https://github.com/nodejs/node/pull/62901
https://github.com/truffle-dev
truffle-devhttps://github.com/truffle-dev
on Apr 24, 2026https://github.com/nodejs/node/issues/62897#issuecomment-4314940085
@bartlomiejuhttps://github.com/bartlomieju
#62901https://github.com/nodejs/node/pull/62901
https://github.com/webdevelopersrinu
webdevelopersrinuhttps://github.com/webdevelopersrinu
on Jul 11, 2026https://github.com/nodejs/node/issues/62897#issuecomment-4947921716
#62901https://github.com/nodejs/node/pull/62901
webdevelopersrinuhttps://github.com/webdevelopersrinu
on Aug 21, 2026https://github.com/nodejs/node/issues/62897#event-29781329011
fs: fix glob early return skipping sibling entrieshttps://github.com/webdevelopersrinu/node/commit/524770450b12152c7e7a93d299c0d43e4d949dd2
5247704https://github.com/webdevelopersrinu/node/commit/524770450b12152c7e7a93d299c0d43e4d949dd2
nodejs-github-bothttps://github.com/nodejs-github-bot
on Aug 23, 2026https://github.com/nodejs/node/issues/62897#event-29864647199
fs: fix glob early return skipping sibling entrieshttps://github.com/nodejs/node/commit/0ea2c86b5b70fdab268597e8c51040c703ee1328
0ea2c86https://github.com/nodejs/node/commit/0ea2c86b5b70fdab268597e8c51040c703ee1328
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#64895https://github.com/nodejs/node/pull/64895
on Aug 23, 2026https://github.com/nodejs/node/issues/62897#event-29864647218
aduh95https://github.com/aduh95
on Aug 25, 2026https://github.com/nodejs/node/issues/62897#event-30010191427
fs: fix glob early return skipping sibling entrieshttps://github.com/nodejs/node/commit/772d9d46820a0a08e705039b7716986505fa4e50
772d9d4https://github.com/nodejs/node/commit/772d9d46820a0a08e705039b7716986505fa4e50
fs: fix glob early return skipping sibling entrieshttps://github.com/nodejs/node/commit/74dcdbb5f1d00cbe47d8ce95906bafc5e5991392
74dcdbbhttps://github.com/nodejs/node/commit/74dcdbb5f1d00cbe47d8ce95906bafc5e5991392
fs: fix glob early return skipping sibling entrieshttps://github.com/nodejs/node/commit/d834d650561922401c33aae3285a8c4670559b68
d834d65https://github.com/nodejs/node/commit/d834d650561922401c33aae3285a8c4670559b68
aduh95https://github.com/aduh95
on Sep 7, 2026https://github.com/nodejs/node/issues/62897#event-30681672540
fs: fix glob early return skipping sibling entrieshttps://github.com/nodejs/node/commit/13b725ca1f1f49fb91592172a0682f6a90c5f8a4
13b725chttps://github.com/nodejs/node/commit/13b725ca1f1f49fb91592172a0682f6a90c5f8a4
fs: fix glob early return skipping sibling entrieshttps://github.com/nodejs/node/commit/c9233b950d1da195a34d219a6ea4e4d6b4a5a9b7
c9233b9https://github.com/nodejs/node/commit/c9233b950d1da195a34d219a6ea4e4d6b4a5a9b7
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/62897
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/62897
confirmed-bugIssues and PRs for confirmed bugs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22confirmed-bug%22
fsIssues and PRs related to file-system APIs and the fs module.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fs%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.