Repository navigation
fix: remove tree field from session detail API to prevent stack overflow on long linear sessions - #38
Closed
fallleave001 wants to merge 1 commit into
Closed
fallleave001 wants to merge 1 commit into
fallleave001 wants to merge 1 commit into
Conversation
…low on long linear sessions sm.getTree() produces a deeply nested chain for long linear sessions (3000+ messages = 3000-level depth), causing JSON.stringify to overflow the call stack. The tree field is unused by the UI.
Owner
|
The stack overflow root cause looks valid, but the fix removes an API field that the UI still consumes for in-session branch navigation. The manual testing only covers long linear sessions. Please also test a session that has used |
This was referenced Jun 4, 2026
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.
Summary
Fix HTTP 500
RangeError: Maximum call stack size exceededwhen loading a session with 2000+ messages that has never used the/treebranch feature.Root Cause
GET /api/sessions/[id]includes thetreefield fromSessionManager.getTree(). For a linear session with no branches, this produces a deeply nested chain where each level contains the next message. With 3523 messages, the tree is 3511 levels deep.NextResponse.json()→JSON.stringify()overflows Node.js's call stack at ~2000 levels.Fix
Remove
tree: mfrom the response JSON. Thetreefield is not used by the UI — session list and message content display correctly without it.Testing
/treebranches