Replies: 2 comments
|
Diagnosis and minimal repro both check out, and the fix is right. What I want to add is that this is one of three open threads describing the same underlying session shape, and one of them is about to touch the exact array that crashes here. The condition behind all three: a long session whose event log is dominated by
The specific collision worth flagging: @nokkies's suggestion on #4678 is to group by
One thing worth adding to your report. The failure is total and permanent for that session — "the session becomes unreadable in the web UI" — from a display-layer routine. That is the same escalation argued on #4703 for the token-accounting underflow: a defect in something that only exists to show you the conversation should not be able to take the conversation away. Saying that explicitly tends to move a fix's priority more than the RangeError does, because it reframes the bug from "history page errors" to "sessions become unrecoverable as they get long" — which, given that the trigger is session length, means every heavy user reaches it eventually. Also worth noting for triage: you are on Interest disclosure: I maintain a third-party DSH plugin. |
|
This exact failure is already fixed on current
I checked the exact current That means a new reference patch would only duplicate upstream work. The useful next verification is whether the first release containing |
Uh oh!
There was an error while loading. Please reload this page.
Environment
Symptom
Loading a long session's history fails with:
history unavailable for session "<session-id>": RangeError: Maximum call stack size exceeded (internal)The session becomes unreadable in the web UI (history load always fails), even though the session data itself is valid.
Root cause
In paginate() (compiled at lib/index.js; source in packages/host/apiproxy):
js const groupStart = sources !== void 0 && sources.length > 0 ? Math.min(event.seq, ...sources) // spreads sourceEventSeqs into arguments : event.seq;A surface-replace �ssistant/message event lists every shadowed chunk seq in sourceEventSeqs. In a large session I inspected, one such event carried 254,780 entries. Spreading that many arguments into Math.min(...) exceeds V8's maximum argument count and throws RangeError: Maximum call stack size exceeded, which the history handler catches and reports as internal ("history unavailable for session ...").
Minimal repro
No session data needed:
js Math.min(0, ...new Array(130000).fill(1)) // RangeError: Maximum call stack size exceededProposed fix
Iterate instead of spreading:
js let groupStart = event.seq; if (sources !== void 0) { for (const source of sources) if (source < groupStart) groupStart = source; }Verified against the real session: pagination completes without error after this change.
Additional note (separate concern)
For such a message the tail page still contains the whole shadowed range (~319k events / ~70 MB JSON in my case), because pagination counts messages but returns raw event ranges. That is a scalability / response-size issue distinct from this crash and worth tracking separately.
All reactions