perf(agent-history): Math.max(...files.map(...)) spread in isDirty can stack-overflow with many sessions
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- desktop-dev, performance
Research direction
Start with apps/desktop/src/main/agent-history/index.ts around line 120, then inspect the matching pattern in usage/store.ts and session-cache.ts around line 318. Replace the spread-based maximum calculations in the named locations and verify that large file or session collections no longer trigger a RangeError.
Written by the indexing model from the issue text.
Description
Problem
apps/desktop/src/main/agent-history/index.ts L120
const maxMtime = files.length > 0
? Math.max(...files.map((f) => f.mtime)) // ← spread of potentially large array
: 0;
Same class of bug as in usage/store.ts: Math.max(...array) passes elements as function arguments via spread. When the files array exceeds ~65,536 entries (large Codex installs), a RangeError is thrown.
Suggested fix
const maxMtime = files.reduce((m, f) => f.mtime > m ? f.mtime : m, 0);
This also eliminates the intermediate map array. The same pattern exists in session-cache.ts L318 and should be fixed there too.
- Dominant language
- TypeScript
- Stars
- 120
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from unbug/tday
-
performance
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
perf(history-store): saveStore uses JSON.stringify with 2-space indent, bloating file size by 30–50% Openperformance
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
performance
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
perf(usage-store): Math.max(...tsValues) spread overflows V8 argument stack on large record sets Openperformance
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
performance
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100