Title: fs.globSync: time grows quadratically with the number of brace expansions · Issue #67711 · nodejs/node · GitHub
Open Graph Title: fs.globSync: time grows quadratically with the number of brace expansions · Issue #67711 · nodejs/node
X Title: fs.globSync: time grows quadratically with the number of brace expansions · Issue #67711 · nodejs/node
Description: Version v26.13.1 Platform Windows 11 x64 (10.0.26300) Subsystem fs (fs.glob, fs.globSync) What steps will reproduce the bug? Save as repro.mjs and run node repro.mjs 15 2, then node repro.mjs 7 4. It globs a pattern of N brace groups wit...
Open Graph Description: Version v26.13.1 Platform Windows 11 x64 (10.0.26300) Subsystem fs (fs.glob, fs.globSync) What steps will reproduce the bug? Save as repro.mjs and run node repro.mjs 15 2, then node repro.mjs 7 4. ...
X Description: Version v26.13.1 Platform Windows 11 x64 (10.0.26300) Subsystem fs (fs.glob, fs.globSync) What steps will reproduce the bug? Save as repro.mjs and run node repro.mjs 15 2, then node repro.mjs 7 4. ...
Opengraph URL: https://github.com/nodejs/node/issues/67711
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fs.globSync: time grows quadratically with the number of brace expansions","articleBody":"### Version\n\nv26.13.1\n\n### Platform\n\n```text\nWindows 11 x64 (10.0.26300)\n```\n\n### Subsystem\n\nfs (`fs.glob`, `fs.globSync`)\n\n### What steps will reproduce the bug?\n\nSave as `repro.mjs` and run `node repro.mjs 15 2`, then `node repro.mjs 7 4`. It globs a pattern of N brace groups with K alternatives each, such as `{a,b}{a,b}{a,b}.html`, in an empty temporary folder. It has no dependencies.\n\n```js\n// Time fs.globSync on a pattern of N brace groups of K alternatives each, in an empty folder.\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nconst dir = fs.mkdtempSync(path.join(os.tmpdir(), \"brace-\"));\nconst max = Number(process.argv[2] ?? 14);\nconst alts = Number(process.argv[3] ?? 2);\nfor (let n = 1; n \u003c= max; n += 1) {\n const group = `{${Array.from({ length: alts }, (_, i) => String.fromCharCode(97 + i)).join(\",\")}}`;\n const pattern = group.repeat(n) + \".html\";\n const start = performance.now();\n fs.globSync(pattern, { cwd: dir });\n console.log(`node ${process.version} groups=${n} alternatives=${alts} expansions=${alts ** n} ${(performance.now() - start).toFixed(1)} ms`);\n}\nfs.rmSync(dir, { recursive: true });\n```\n\n### How often does it reproduce? Is there a required condition?\n\nEvery run. The only condition is a pattern whose braces expand to thousands of patterns. The folder can be empty.\n\n### What is the expected behavior? Why is that the expected behavior?\n\nTime roughly proportional to the number of expanded patterns. With no files to match, each pattern should cost about the same however many there are.\n\n### What do you see instead?\n\nThe cost of each pattern grows with the number of patterns, so the total grows roughly quadratically:\n\n```text\ngroups=10 alternatives=2 expansions=1024 56.2 ms (~55 µs per pattern)\ngroups=11 alternatives=2 expansions=2048 115.6 ms\ngroups=12 alternatives=2 expansions=4096 272.9 ms\ngroups=13 alternatives=2 expansions=8192 729.7 ms\ngroups=14 alternatives=2 expansions=16384 4660.6 ms\ngroups=15 alternatives=2 expansions=32768 28038.2 ms (~856 µs per pattern)\n\ngroups=5 alternatives=4 expansions=1024 56.5 ms\ngroups=6 alternatives=4 expansions=4096 254.6 ms\ngroups=7 alternatives=4 expansions=16384 1777.6 ms\n```\n\nAt the same expansion count (16,384), two-way groups are slower than four-way groups (4.7 s vs 1.8 s), so the cost also depends on how the groups nest, not only on the number of patterns. A CLI that passes a user's glob to `fs.globSync` looks hung on a pattern like this, with no error.\n\n### Additional information\n\nMeasured on Windows only. We now refuse globs that expand to more than 1,024 patterns before calling `fs.globSync`.\n","author":{"url":"https://github.com/gustavohrm","@type":"Person","name":"gustavohrm"},"datePublished":"2026-11-22T21:21:50Z","url":"https://github.com/nodejs/node/issues/67711"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:50cd3787-84e0-7e04-7da4-6f1a115a2fdf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9586:12B33:3BEBB6:4E22F8:6B061973 |
| html-safe-nonce | 6cce11b0818bada4027ee966ed42391adceb7da5547b1e8d9a0b6206c9b06482 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTg2OjEyQjMzOjNCRUJCNjo0RTIyRjg6NkIwNjE5NzMiLCJ2aXNpdG9yX2lkIjoiNzE2NDkwMzEyNTQ1ODIyOTYxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e0cdd89a9ad1492212ca4bba122cab36f19887f8ff610e7cace1612287dbaf7b |
| hovercard-subject-tag | issue:6547953206 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/67711/issue_layout |
| twitter:image | https://opengraph.githubassets.com/22044cb44a5fdd4f81ae3abdd61d01badca8a30116048630a8bec34ae23a4d70/nodejs/node/issues/67711 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/22044cb44a5fdd4f81ae3abdd61d01badca8a30116048630a8bec34ae23a4d70/nodejs/node/issues/67711 |
| og:image:alt | Version v26.13.1 Platform Windows 11 x64 (10.0.26300) Subsystem fs (fs.glob, fs.globSync) What steps will reproduce the bug? Save as repro.mjs and run node repro.mjs 15 2, then node repro.mjs 7 4. ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gustavohrm |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width