Title: mcpx: successor daemon never waits for background orphan-session DELETEs on shutdown — WaitOrphanTerminations has no production caller · Issue #298 · developing-today/code · GitHub
Open Graph Title: mcpx: successor daemon never waits for background orphan-session DELETEs on shutdown — WaitOrphanTerminations has no production caller · Issue #298 · developing-today/code
X Title: mcpx: successor daemon never waits for background orphan-session DELETEs on shutdown — WaitOrphanTerminations has no production caller · Issue #298 · developing-today/code
Description: Problem Since #291 / PR #296, a successor daemon ends a removed server's orphaned upstream HTTP session in background goroutines started by Adoption.Attach() (pkgs/mcpx/internal/daemon/registry_handoff.go, Attach). Adoption.WaitOrphanTer...
Open Graph Description: Problem Since #291 / PR #296, a successor daemon ends a removed server's orphaned upstream HTTP session in background goroutines started by Adoption.Attach() (pkgs/mcpx/internal/daemon/registry_han...
X Description: Problem Since #291 / PR #296, a successor daemon ends a removed server's orphaned upstream HTTP session in background goroutines started by Adoption.Attach() (pkgs/mcpx/internal/daemon/registry...
Opengraph URL: https://github.com/developing-today/code/issues/298
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: successor daemon never waits for background orphan-session DELETEs on shutdown — WaitOrphanTerminations has no production caller","articleBody":"## Problem\n\nSince #291 / PR #296, a successor daemon ends a removed server's orphaned upstream HTTP session in background goroutines started by `Adoption.Attach()` (`pkgs/mcpx/internal/daemon/registry_handoff.go`, `Attach`). `Adoption.WaitOrphanTerminations()` exists to wait for those goroutines — its own doc comment says \"Production serving never waits for it; it exists for tests and orderly shutdown\", and the `orphanWG` field comment frames it as for \"a shutdown that wants a clean slate\".\n\n**No production code ever calls it.** Verified on main `f7efb040`:\n\n- `grep -rn WaitOrphanTerminations pkgs/mcpx/internal/daemon` → only the definition (`registry_handoff.go:187`) and two test callers (`registry_handoff_test.go:168`, `:205`).\n- The one production `Adoption` is a local in `commitTakeover` (`pkgs/mcpx/internal/daemon/takeover.go:637` `ad, err := s.reg.Adopt(in.pools)`, `:664` `ad.Attach()`) and is discarded when `commitTakeover` returns; the `Server` struct retains no reference to it.\n- `Server.shutdown()` (`pkgs/mcpx/internal/daemon/server.go`, ~:471) flushes caches, calls `stopServing()`, removes the socket/record and returns — it never waits for orphan terminations.\n- `Server.Serve()`'s handed-off case returns `nil` directly, after which the caller in `pkgs/mcpx/internal/cli/root.go:427` returns and the process exits — that path doesn't wait either.\n\n## Why it matters\n\nEach orphan DELETE is bounded only by `upstream.sessionDeleteTimeout` (5s, `pkgs/mcpx/internal/defaults/defaults.json:260`), and the async move in #291 was motivated exactly by upstreams that never answer. A successor that stops — or hands off again — inside that window (a quick upgrade/restart, an idle-exit daemon, a crash-free short-lived run) exits with the DELETEs still in flight; process exit kills the goroutines, so the session is never ended and leaks upstream until it expires. That silently defeats #260's \"exactly one DELETE, post-commit\" guarantee in precisely the unreachable-upstream case.\n\nThe same code in the dezren39/nix mcpx copy has the identical gap (its `WaitOrphanTerminations` likewise has test-only callers).\n\n## Suggested fix\n\n- Retain the `Adoption` from a committed takeover on the `Server` (e.g. an `atomic.Pointer[Adoption]` set in `commitTakeover` after the commit succeeds; the abort path must not retain/wait — it sends no DELETEs by design).\n- Wait for orphan terminations on the orderly exit paths: `shutdown()`, and the handed-off return in `Serve()` (that daemon's own orphan DELETEs are not part of the next handoff, so nobody else will finish them).\n- Keep the wait bounded in effect: terminations already run in parallel and each is capped by the 5s delete timeout; if a separate overall bound is preferred, make it explicit and log when it expires rather than blocking shutdown indefinitely.\n\n## Acceptance criteria\n\n- [ ] After a takeover that orphans a session whose DELETE is blocked/slow, `shutdown()` does not return until the DELETE has completed (or an explicit bound expires and is logged); the upstream still sees exactly one DELETE.\n- [ ] The handed-off exit path in `Serve()` likewise does not return while this daemon's orphan terminations are in flight.\n- [ ] A successor that never took over, or whose takeover aborted, shuts down exactly as before (no wait, no DELETE).\n- [ ] New regression test at the Server level (a blocked-DELETE takeover followed by shutdown), in the style of `registry_handoff_test.go`'s blackholed-upstream test for #291.\n- [ ] `go test ./internal/daemon/ ./internal/pool/` green; existing takeover/abort tests unchanged and passing.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-18T16:33:30Z","url":"https://github.com/developing-today/code/issues/298"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:23452d9e-9f62-5e56-a49f-17edad38e117 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E21A:38AE1E:1215EE:17BDF2:6B06271D |
| html-safe-nonce | 2f997a2a871121276afb9241d1e9f9dc8c7b34067e55bb15b5d0a172c7ed4f40 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjFBOjM4QUUxRToxMjE1RUU6MTdCREYyOjZCMDYyNzFEIiwidmlzaXRvcl9pZCI6IjUyNDUxNjk4NDIxMzQ1OTEyNjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d422144f61c35c2f7ed67e8289a092bcca2c13e0ac92cdcf87d106233a5fe0ba |
| hovercard-subject-tag | issue:5911688295 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/298/issue_layout |
| twitter:image | https://opengraph.githubassets.com/990cdc49de300fe28332e4c4d8427f6585b079546478437a03a9fca9585f2683/developing-today/code/issues/298 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/990cdc49de300fe28332e4c4d8427f6585b079546478437a03a9fca9585f2683/developing-today/code/issues/298 |
| og:image:alt | Problem Since #291 / PR #296, a successor daemon ends a removed server's orphaned upstream HTTP session in background goroutines started by Adoption.Attach() (pkgs/mcpx/internal/daemon/registry_han... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9e10bb0ecc0bd0f8692aa89586ee9b54e498d7ab9f244a44cdb5b93653a125ce |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 32e57d5cc2ce6ce92ec6dceb65858344750c27c2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width