Problem
apps/desktop/src/main/usage/store.ts L153–154
const tsValues = records.map((r) => r.ts); // intermediate array
const spanMs = tsValues.length > 1
? Math.max(...tsValues) - Math.min(...tsValues) // ← spread
: 0;
Math.max(...array) passes array elements as function arguments via spread. V8's function call argument limit is ~65,536. When records exceeds that count, a RangeError: Maximum call stack size exceeded is thrown.
Suggested fix
Replace the spread with a reduce or for loop:
let minTs = Infinity, maxTs = -Infinity;
for (const r of records) {
if (r.ts < minTs) minTs = r.ts;
if (r.ts > maxTs) maxTs = r.ts;
}
This also eliminates the intermediate tsValues array allocation, saving one O(n) pass.
Problem
apps/desktop/src/main/usage/store.tsL153–154Math.max(...array)passes array elements as function arguments via spread. V8's function call argument limit is ~65,536. Whenrecordsexceeds that count, aRangeError: Maximum call stack size exceededis thrown.Suggested fix
Replace the spread with a
reduceorforloop:This also eliminates the intermediate
tsValuesarray allocation, saving one O(n) pass.