GeezerVison is showing github.com — mcpx: DELETE a removed server's upstream session on takeover (#260) by dezren39 · Pull Request #267 · developing-today/code
Conversation
dezren39
commented
Oct 18, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Problem
Fixes #260. On daemon takeover (mcpx upgrade / mcpx daemon --takeover), the upstream streamable-HTTP session of a server removed from the configuration was orphaned: no pool adopted it, no transport was ever built for it, and no session-termination DELETE was sent — the session was left to expire upstream, silently. pkgs/mcpx/TODO.md recorded this as known-not-done. This is the same defect fixed in dezren39/darwin-nix#390 by PR #391; this repo's pkgs/mcpx copy did not have that fix (pre-fix files verified byte-identical to the nix pre-fix versions).
Solution (port of dezren39/nix PR #391)
- Handoff carries the endpoint:
mcpclient.HTTPHandoff gains URL + Headers (populated at Detach; travels only over the takeover unix socket), and pool.PoolHandoff gains Server.
Registry.Adopt records the HTTP sessions of pools with no match as orphan sessions (no upstream contact at adopt time).
Adoption.Attach (post-commit only) ends each orphan session with exactly one DELETE via pool.TerminateOrphanedSession → mcpclient.TerminateHTTPSession (404 counts as already ended). Abort contacts nothing, so the predecessor keeps its session.
- Failures are no longer silent:
upstream.session.orphaned (server + session + reason) vs upstream.session.terminated lifecycle events. HTTPTransport.Close keeps best-effort semantics; the DELETE error surfaces only through the new termination path.
- TODO.md line recording the gap removed.
Verification
- New daemon regression tests:
TestTakeoverTerminatesARemovedServersUpstreamSession (exactly one DELETE with sess-1 after commit) and TestAbortedTakeoverLeavesARemovedServersSessionAlone (no DELETE, predecessor keeps serving).
- Ablation: with the fix stashed, the takeover test fails — upstream saw 0 DELETEs. With the fix, it passes.
- New pool tests:
TestTerminateOrphanedSessionEndsTheUpstreamSession, TestTerminateOrphanedSessionReportsAnUnreachableEndpoint.
go test ./internal/pool/ ./internal/daemon/ ./internal/mcpclient/ — all green. go build ./... clean, go vet clean, changed files gofmt-clean.
Summary by CodeRabbit
- Bug Fixes
- Upstream sessions for servers removed during a takeover are now terminated after the takeover completes, rather than being left to expire on their own.
- If a takeover is aborted, the predecessor keeps its session active.
- If an orphaned session cannot be terminated, the system records the failure; successful termination is also recorded.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
A takeover handed an HTTP session on with Abandon, expecting the successor to own it — but a server removed from the configuration (or changed enough to be a different pool) had no pool to adopt it, so the session was silently left to expire upstream.
The handoff now carries the session's endpoint and headers (over the takeover unix socket only), and PoolHandoff names its server. A successor records the HTTP sessions no pool adopted and, in Attach — after the handoff has committed — ends each one with mcpclient.TerminateHTTPSession (exactly one DELETE with the session id). On abort nothing is contacted, so the predecessor keeps the session. A session that cannot be terminated is reported as upstream.session.orphaned with the server and session id instead of being dropped silently; a successful end is upstream.session.terminated.
Ports dezren39/nix PR #391 (fix for dezren39/darwin-nix#390) to this repo's pkgs/mcpx copy, whose pre-fix files were byte-identical. TODO.md line recording this gap is removed.
|

Note Currently processing new changes in this PR. This may take a few minutes, please wait...
⚙️ Run configuration
-
- Configuration used: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f998a948-f941-4ac4-b33d-db92cb2ba95b
📥 Commits
-
Reviewing files that changed from the base of the PR and between f646156 and 9febf3c.
📒 Files selected for processing: 6
-
pkgs/mcpx/TODO.md
pkgs/mcpx/internal/daemon/registry_handoff.go
pkgs/mcpx/internal/daemon/registry_handoff_test.go
pkgs/mcpx/internal/mcpclient/http.go
pkgs/mcpx/internal/pool/handoff.go
pkgs/mcpx/internal/pool/upstream_session_test.go
+--------------------------------------------------------------------------------+
| Please don't use comments to explain what code should be doing. Make it do it. |
+--------------------------------------------------------------------------------+
\
\ /)/)
( '')
/ |
o(___)
✨ Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Oct 18, 2026
This was referenced Oct 28, 2026
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
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.
|