fix: avoid array spread when merging messages - #10
Merged
evanlong-me merged 1 commit intoSep 16, 2026
Merged
Conversation
Array.prototype.push with a spread passes every element as its own argument; V8 throws RangeError: Maximum call stack size exceeded past roughly 100k arguments. With 120k messages in ~/.claude/projects the merge in autoDetect crashed the whole run. All three merge sites now push in a loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
muaborts with❌ Error fetching usage data: Maximum call stack size exceededand printsnothing once a source returns more than roughly 100k messages. My
~/.claude/projects/holds120,654 assistant messages, which is enough to hit it on every run — with and without
-s,and
-t/-pare no workaround because filtering happens after the merge.The three merge sites append with a spread, so every message becomes its own argument to
Array.prototype.pushand V8 throws past its argument limit:src/usage.ts:76— merges all sources, the one that actually fails todaysrc/sources/claude.ts:64andsrc/sources/pi.ts:64— still below the threshold becausethey accumulate per directory, but the same failure waits there
Closes #9
How
Each site pushes in a loop instead. One comment per site names the trap, so the spread does
not come back as a "simplification" later:
No behaviour change beyond not crashing: same messages, same order, same totals. Fixing only
usage.tswould have left two loaded guns in the adapters, which is why all three are inhere — it is the same one-line change three times, not three concerns.
Verification
npm run buildpassesnode dist/cli.jswith the affected flagssrc/cli.tsstay in sync)Details:
Docs need no change — the observable behaviour is unchanged, the command simply stops
crashing. No new flags, no new output, so README.md, AGENTS.md and the help text in
src/cli.tsstay as they are.No tests: the repo has no test setup, and a regression test for this would have to build
100k+ objects to trip the limit. Happy to add one if you want the infrastructure.