{"author":{"id":"MDQ6VXNlcjM4OTY5OTg=","is_bot":false,"login":"yazydzhi","name":"Vladimir Yazydzhi"},"body":"## What happened\n\nAny host command that recursively lists paths — \\`bb.sdk.files.listPaths\\`/\\`listPathsRecursively\\` under the hood — crashes on a workspace with a large enough file tree. In practice this shows up as an opaque \\`HTTP 502\\` from any caller (e.g. a plugin's \\`listTree\\` RPC), with no useful error surfaced to the user.\n\nRepro: point a project/vault at a directory with roughly 100k+ files somewhere in its tree (a large Obsidian vault, a big monorepo, etc.) and call file listing/search on it.\n\n## Root cause\n\n\\`apps/host-daemon/src/command-handlers/file-list.ts\\`, \\`listPathsRecursively\\`, merges each subdirectory's results like this:\n\n\\`\\`\\`ts\nresults.push(\n  ...(await listPathsRecursively({ ...args, dir: fullPath })),\n);\n\\`\\`\\`\n\n\\`Array.prototype.push(...arr)\\` spreads every element of \\`arr\\` onto the JS call stack as individual arguments. Once a subtree's accumulated result array crosses V8's argument-count ceiling (~100k, engine-dependent), this throws:\n\n\\`\\`\\`\nRangeError: Maximum call stack size exceeded\n\\`\\`\\`\n\nwhich propagates up as an unhandled error and surfaces to callers as a 502.\n\nMinimal repro of the underlying JS behavior:\n\n\\`\\`\\`js\nconst results = [];\nconst big = new Array(200_000).fill(0).map((_, i) => ({ path: \"x\" + i }));\nresults.push(...big); // RangeError: Maximum call stack size exceeded\n\\`\\`\\`\n\n## Fix\n\nReplace the spread-push with a plain loop (no argument-count limit). PR: #<!-- filled in below -->\n\nAdded a regression test in \\`file-list.test.ts\\` that creates a 150k-file subtree and asserts \\`listPathsRecursively\\` returns instead of throwing; confirmed it reproduces the exact \\`RangeError\\` against the current code and passes with the fix.","comments":[],"labels":[{"id":"LA_kwDORYGSE88AAAACw4ga9w","name":"workspaces","description":"Worktrees, environments, git, shells","color":"fbca04"},{"id":"LA_kwDORYGSE88AAAACw4gbWQ","name":"host","description":"Host daemon, process lifecycle, memory, event loop","color":"b60205"}],"number":2362,"projectItems":[],"state":"OPEN","title":"File listing crashes with 502 on large workspaces (Maximum call stack size exceeded)","url":"https://github.com/get-bb/bb/issues/2362"}
