feat(core): [Unhandled Sessions 1] Add Unhandled session state and pending marker - #5916
Merged
buenaflor merged 2 commits intoAug 10, 2026
Merged
Conversation
Adds Session.State.Unhandled from the session protocol, plus a pending-unhandled marker that survives serialization. A session carrying the marker finalizes as Unhandled instead of Exited on end(), while Crashed and Abnormal keep taking precedence. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
📲 Install BuildsAndroid
|
This was referenced Aug 10, 2026
Contributor
Performance metrics 🚀
|
"Unhandled" alone is ambiguous: a native crash is also an unhandled error, it just terminates the process and so ends the session as crashed rather than unhandled. Name the flag after the property that actually distinguishes the two and match the vocabulary of captureEnvelopeNonTerminating. Also clarify that the setter only restores the flag when rebuilding a session and must not be used to mutate a live one. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
Not actually merged into The collection branch has been restored to its empty commit and the stack rebuilt unchanged. This PR continues as #5919. |
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.
PR Stack (Unhandled Sessions)
📜 Description
Adds the
unhandledsession status to the session model.Session.State.Unhandled— the protocol status for an unhandled error that did not terminate the process.pendingUnhandledmarker onSession(pending_unhandledwhen serialized) that records "this session saw an unhandled error" without ending the session or changing its status while it is still alive.end()finalizes a session carrying the marker asUnhandledinstead ofExited.CrashedandAbnormalkeep taking precedence, andupdate(Crashed, ...)clears the marker so a real crash always wins.clone()and the (de)serializer carry the marker; it is omitted from JSON when unset.Nothing sets the marker yet — this PR is inert on its own. It is the model layer for the rest of the stack.
💡 Motivation and Context
Hybrid runtimes such as Flutter report
handled=falseexceptions that do not kill the process. Today those go through the terminating capture path, which marks the sessioncrashedand starts a replacement session even though the app keeps running, incorrectly lowering crash-free session rates.The session protocol has had a dedicated status for exactly this case since 1.6.0:
unhandled— "an unhandled error occurred but the process did not terminate". Relay accepts it (SessionStatus::Unhandled→"unhandled").💚 How did you test it?
New
SessionTestcovering the marker's atomic update, terminal-state precedence (Crashed/Abnormalwin),clone(), and serialization round-trips.PreviousSessionFinalizerTestcovers recovery of a previous session carrying the marker, including a native crash escalating it tocrashed.SessionSerializationTestcovers the JSON round-trip.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Persisting the marker across process death and exposing the capture API, in the following PRs in this stack.
#skip-changelog