Title: mcpx: EnsureDaemon poll-loop exit drops a cancellation — no post-loop ctx.Err() check (nix copy has it) · Issue #328 · developing-today/code · GitHub
Open Graph Title: mcpx: EnsureDaemon poll-loop exit drops a cancellation — no post-loop ctx.Err() check (nix copy has it) · Issue #328 · developing-today/code
X Title: mcpx: EnsureDaemon poll-loop exit drops a cancellation — no post-loop ctx.Err() check (nix copy has it) · Issue #328 · developing-today/code
Description: Finding The two mcpx copies have diverged in Client.EnsureDaemon's poll loop exit path (pkgs/mcpx/internal/cli/client.go): dezren39/nix (reference, from its #233 fix): after the poll loop, client.go:403-405 re-checks the context before r...
Open Graph Description: Finding The two mcpx copies have diverged in Client.EnsureDaemon's poll loop exit path (pkgs/mcpx/internal/cli/client.go): dezren39/nix (reference, from its #233 fix): after the poll loop, client.g...
X Description: Finding The two mcpx copies have diverged in Client.EnsureDaemon's poll loop exit path (pkgs/mcpx/internal/cli/client.go): dezren39/nix (reference, from its #233 fix): after the poll loop, clie...
Opengraph URL: https://github.com/developing-today/code/issues/328
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx: EnsureDaemon poll-loop exit drops a cancellation — no post-loop ctx.Err() check (nix copy has it)","articleBody":"## Finding\n\nThe two mcpx copies have diverged in `Client.EnsureDaemon`'s poll loop exit path (`pkgs/mcpx/internal/cli/client.go`):\n\n- **dezren39/nix** (reference, from its #233 fix): after the poll loop, client.go:403-405 re-checks the context before reporting the timeout:\n ```go\n if err := ctx.Err(); err != nil {\n return err\n }\n ```\n- **developing-today/code** (this repo, current main 2e9cf192): the loop at client.go:395-403 is followed immediately by the log-tail read and the generic error at client.go:409 — there is no post-loop `ctx.Err()` check. This repo's #284 fix (PR #285) ported the entry, remote and after-ping checks from #233, plus the in-loop `select` on `ctx.Done()`, but not the post-loop check.\n\nThe in-loop `select` catches a cancellation that lands while the loop is waiting. It does not catch one that becomes visible only as the loop exits on the connect deadline — e.g. a context whose `Done` channel has not fired (or fires in the same instant the deadline passes) but whose `Err()` is already set when the deadline expires. In that window this copy reports:\n\n```\ndaemon did not become ready; see \u003cstate>/daemon.log\n```\n\nfor a caller who cancelled, instead of `context.Canceled`. Callers that branch on `errors.Is(err, context.Canceled)` (prompt-exit paths, shutdown) misread a cancellation as a daemon failure.\n\n## Evidence\n\n- nix: `sed -n '395,410p' pkgs/mcpx/internal/cli/client.go` in dezren39/nix @ 295b70d shows the post-loop check between the loop and the `tail, _ := os.ReadFile(logPath)` line.\n- code: the same range in this repo @ 2e9cf192 goes straight from the loop's closing brace to `tail, _ := os.ReadFile(logPath)`.\n- A normalized cross-copy diff of `pkgs/mcpx` (issue numbers and whitespace stripped) shows this is the only remaining behavioural divergence in `EnsureDaemon`; `internal/cli/connect.go` (inlineDaemon, #430 set) is byte-identical.\n\n## Acceptance criteria\n\n- [ ] Code's `EnsureDaemon` re-checks `ctx.Err()` after the poll loop and returns it when set, mirroring dezren39/nix client.go:403-405.\n- [ ] A regression test in BOTH copies pins the exit path deterministically: a context that reports `context.Canceled` from `Err()` only after the entry checks (its `Done` channel never fires) with a short connect timeout must yield `context.Canceled`, not \"daemon did not become ready\". The test must fail on this repo's current code and pass in nix both before and after (nix already has the check but no test pinning this exit path — the same gap code #323 records for inlineDaemon's poll).\n- [ ] Existing EnsureDaemon tests (already-cancelled, cancel-while-polling, remote-cancelled, never-ready timeout) stay green in both copies.\n\nCross-repo: one issue here (the defect is only in this copy); the nix side is test-only and is solved as part of this set with a PR referencing this issue.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-19T01:56:52Z","url":"https://github.com/developing-today/code/issues/328"}
| 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:fc9d630e-afc8-d656-2dd2-37e673578379 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8030:8007E:47D8A1:5FB0C5:6B061E7F |
| html-safe-nonce | f852ae6c6941f8b080f6aaee708473cc2aeaf5bbd71f3e0a24ec0af8a6411f16 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDMwOjgwMDdFOjQ3RDhBMTo1RkIwQzU6NkIwNjFFN0YiLCJ2aXNpdG9yX2lkIjoiNTI4MTYwNTQ3MTM0MDczMjAzMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 789134479e5778c9e3473862dfd0417fc9a21aff466706195402689eca798318 |
| hovercard-subject-tag | issue:5916481370 |
| 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/328/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7643f5950aea15cb337119bb8017de896270e80fbd9442c7add21b69c8639230/developing-today/code/issues/328 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7643f5950aea15cb337119bb8017de896270e80fbd9442c7add21b69c8639230/developing-today/code/issues/328 |
| og:image:alt | Finding The two mcpx copies have diverged in Client.EnsureDaemon's poll loop exit path (pkgs/mcpx/internal/cli/client.go): dezren39/nix (reference, from its #233 fix): after the poll loop, client.g... |
| 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 | 9a7c5824b75ea2ec5e3de73a483229c7bb9f32a774ffd401f010dd9bacf1483d |
| 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 | b25c3080e84402f75431d8dc7a96b2635219cec7 |
| 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