Repository navigation
Give session recovery one owner - #500
Merged
Merged
Conversation
A recovery is one task that the session owns. Callers wait for it without owning it, so cancelling a waiting call no longer abandons the recovery and leaves the connection unavailable. A recovery ends when the replacement is initialized, when its deadline passes, or on close. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The deadline now fails a recovery whichever step it has reached, so a transport that is still being created cannot keep the session recovering. Leftover work moves to a cleanup that close() waits for, and a later reconnect starts at once. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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
Session recovery in
MCPClientSessionAuthoritynow has one owner, and a recovery continues after its last waiting caller is cancelled or times out. Before, that recovery was abandoned and the connection stayed.unavailableuntilreconnect(timeout:), so cancelling one call during a recovery made every later call fail.Details
Recoveryholds its attempt task, a deadline task, the replacement connection, and the continuations of waiting callers. Waiters are only notified; they no longer keep the recovery alive.requestTimeoutpasses (30 seconds when it isnil, as for the first connection), or when the session closes. A caller with a longer or disabled timeout no longer extends a recovery past that bound.close()waits for. A laterreconnect(timeout:)starts at once, and a transport that arrives late is closed without being initialized.performManagedHandshakefrom the first connection. The detached handshake with its per-step authorization, the background lease, and the table of retired recoveries are removed. The file goes from 1,686 to 1,093 lines.close()waits for a transport that is being created and for an event stream that is starting, and the bound without a default timeout.Review focus
The local Codex review left two findings that this PR does not change.
.ready. I kept this: the connection works, and failing it would discard a usable connection.startEventStreamnever returns after cancellation would keep a session alive after its client dropped it withoutclose(). The shipped transports return fromstartEventStreamat once (HTTP starts a task; the process transport does nothing), so I did not restore the detached handshake to cover it.Testing
swift build --build-tests: succeeded.swift test --no-parallel --filter XcodeMCPKitTests: 63 tests passed in 12 consecutive runs.swift test --no-parallel --filter 'XcodeMCPKitTestingTests|ProxyToolVerifierTests|ProxyIntegrationTests': 133 tests passed.PublicProductContractTestspassed before the second commit, which did not change public API.🤖 Generated with Claude Code