From b314cf16cea6f81b3464ad70dde29d3b1d725a47 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Thu, 27 Aug 2026 11:27:35 -0700 Subject: [PATCH] fix(host-service): stop usage.history throwing on very large usage histories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit collectUsageEntries appended the deduped Claude entries with entries.push(...map.values()), which passes every entry as a call argument. Past V8's argument limit (~125k entries in the worker) that throws RangeError: Maximum call stack size exceeded, so usage.history failed deterministically for exactly the heaviest users. Append in a loop instead — stack usage no longer scales with entry count. Refs HOST-SERVICE-4V Claude-Session: https://claude.ai/code/session_0133xN5zZ3goUNfKAy9cLfA9 --- .../host-service/src/trpc/router/usage/history/entries.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/host-service/src/trpc/router/usage/history/entries.ts b/packages/host-service/src/trpc/router/usage/history/entries.ts index eaf1e611f9f..e1dc489c323 100644 --- a/packages/host-service/src/trpc/router/usage/history/entries.ts +++ b/packages/host-service/src/trpc/router/usage/history/entries.ts @@ -80,7 +80,12 @@ export async function collectUsageEntries( sessionLabels, ); } - entries.push(...claudeEntriesByMessage.values()); + // Appended one at a time — spreading into push() passes every entry as a + // call argument, which throws RangeError past V8's argument limit on + // machines with a large enough usage history. + for (const entry of claudeEntriesByMessage.values()) { + entries.push(entry); + } for (const file of codexFiles) { await parseCodexLogFile(file, cutoffMs, entries, sessionLabels); }