Repository navigation
fix(http): Isolate session stream conflicts from shared transport - #303
Merged
benbrandt merged 4 commits intoOct 22, 2026
Conversation
federicociner
marked this pull request as ready for review
October 21, 2026 01:41
- Give each session SSE stream its own AbortController so a session that fails on a POST 409 is fully detached; a later reattach opens a fresh stream instead of reusing the stale one. - Clear the failure on session/resume as well as session/load (v2 has no session/load). - Keep response routing for failed sessions so late responses to server requests are discarded instead of being posted without a session header, which could still tear down the shared connection. - Only clear session stream entries owned by the closing stream. - Parse JSON error bodies into the synthesized error's data. - Add tests for SSE and POST 409 conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A session SSE stream closing while requests are in flight previously tore down the shared transport. Now only that session's pending requests fail with JSON-RPC errors, and the next session message reopens the stream. Also document session-scoped failure handling on createHttpStream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
A session-scoped HTTP 409 currently terminates the shared HTTP transport, making unrelated sessions on the same connection unusable.
This occurs when a server rejects a session stream’s saved position and requires an explicit reload. The conflict applies to that session, but
openSse()callserrorReadable(), which aborts all streams and deletes the connection. Rejecting the corresponding writable operation can also leave the shared writer permanently errored.This change:
session/loadorsession/resumeto detach the failed stream and attempt a fresh stream attachment.Requests and prompts are not automatically replayed.
Reproduction
We reproduced the failure using the real ACP SDK with a controlled fetch implementation:
{"code":"session_reload_required"}Before the fix, B’s conflict terminates the shared transport. Other sessions fail, and a client retaining that transport cannot use it for subsequent sessions. Creating a fresh transport succeeds.
With the fix, B receives a correlated error, A’s pending request completes, and a new session C works on the original connection. No connection DELETE occurs. An explicit load can retry B.