Repository navigation
fix(mcpx): honour a cancelled context in EnsureDaemon (#284) - #285
Merged
Merged
Conversation
EnsureDaemon never checked ctx.Err(): a ping that failed because the caller's context was cancelled was read as 'no daemon', so it spawned a daemon anyway and the readiness poll waited out the full autostart.connectTimeout (20s by default) before failing with 'daemon did not become ready'. Check ctx.Err() up front and after each failed ping, and select on ctx.Done() in the poll loop. Regression tests cover the already-cancelled case, cancellation while waiting, and the unchanged never-ready timeout.
Codex Review SummaryThis 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 2
✨ Finishing Touches
Comment |
3 tasks
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.
Fixes #284.
What
EnsureDaemon(pkgs/mcpx/internal/cli/client.go) ignored a cancelled context: aPingthat failed because the context was cancelled was read as "no daemon", so it spawned a daemon the caller no longer wanted, and the readiness poll (which never selected onctx.Done()) waited out the fullautostart.connectTimeout— 20s by default — before failing withdaemon did not become readyinstead ofcontext.Canceled.ctx.Err()at the top ofEnsureDaemonand after each failedPing, before treating the failure as absence.ctx.Done()alongside the poll interval and returnsctx.Err().Verification
228019a1before the fix: already-cancelled context → fake daemon spawned, 3.03s waited (the configured timeout), wrong error.internal/cli/ensuredaemon_test.go:TestEnsureDaemonAlreadyCancelledContext— promptcontext.Canceled, no spawn.TestEnsureDaemonCancelledWhileWaiting— cancel at 200ms against a 30s timeout returns promptly (ablation: pre-fix this took 30.03s and returned the timeout error).TestEnsureDaemonNeverReadyStillTimesOut— uncancelled behaviour unchanged: spawns, waits the timeout, same error.go test ./internal/cli/passes;go build ./...clean;go vetclean; changed files gofmt-clean (pre-existingconsumer.goformatting drift on main left untouched).Same defect is tracked for the dezren39/nix copy as dezren39/darwin-nix#233; the fix here follows that issue's suggested approach.
Summary by CodeRabbit