Repository navigation
fix(mcpx): revive exited supervised child on spawn-intent re-dial (#17226) - #17310
Merged
Merged
Conversation
#17226) NewSupervised (the pool spawn dial) accepted a transport born exited when its attach landed while the supervisor was still serving the child exit report: every Send on it fails with "child already exited". The era-probe recovery re-dials exactly then — the probe discover has just killed a legacy server that exits on any first message but initialize — so the ForceLegacy retry initialize was refused by the dead transport itself, the start failed, and the pool restart cooldown failed the call (nightly run 46433738642, macOS leg). A born-exited attach is now closed and retried through the supervisor restart action, which revives the child (#9963); if the supervisor is gone the dial falls through to the ordinary spawn. Regression test: kill the child while unattached (the supervisor then serves the exit report for its #16797 grace), re-dial, and require a live echo from a new child pid.
…tached supervisor grace)
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
This was referenced Nov 30, 2026
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.
Closes #17226
Root cause
Slice 2 of the #17221 nightly stress failure (macOS e2e
TestTheEraIsProbedOnceAndRememberedAcrossDaemonRestarts/…/legacy-exiting-on-discover-is-reached, era_test.go:118):server/discover; a legacy server that exits on any first message butinitialize(testsupport/eramcplegacy-exit) dies, so the probe returnsErrClosedDuringProbe.ForceLegacyretry.SupervisedTransport.exitedis set at attach and never updated.initializeis refused by the dead transport itself:initialize: write to …/eramcp (supervised): child already exited: exit status 1. Start fails → pool failCount=1 → 2s restart cooldown → the call trips over the cooldown (1.999s in the nightly log).The window is the gap between the supervisor recording the exit and finishing its exit-report shutdown; under macOS stress the supervisor's exit path is delayed enough for the re-dial to land inside it. The pool-level probe test passes because it uses direct stdio (no supervisor).
Fix
newSupervised(the spawn-intent dial; its only production caller is the pool'sdialSpawn): when the initial attach succeeds but the transport is born exited, close it and revive the child through the supervisor's existingrestarthandshake action (#9963: an exited child is simply revived), retrying briefly while the reporting detach is processed. If the supervisor is gone or stays refused, fall through to the existing spawn path unchanged. Attach-only dials (AttachSupervised, restart dials) keep the reporting semantics — the exit report is a feature for observers, just not for a dial that needs a live child.Regression test
TestSupervisedRedialAfterChildExitRevivesChild(internal/mcpclient): a hand-started supervisor runsexitchild(exits immediately); with no attach ever made, the supervisor parks in its never-attached wait holding the dead child, so a raw-handshake probe confirmschildState="exited"and the dial lands in the reporting window deterministically. The test then requires Send to work and the revived child's frame to arrive.Failing-first proof (test-only branch, no fix), remote run 46464462350:
— the production error shape. With the fix: run 46464552018 passes.
Verification (remote dispatch, this branch on current main)
go test ./internal/mcpclient/ -race -shuffle=6839106235133155819 -count=3(nightly seed) +gofmt+go vet— run 46465718752 ✅ (also: fullTestSupervised*suite at-count=5, run 46456537008 ✅)go test ./internal/pool/ -race -shuffle=6839106235133155819 -count=3 -run 'TestPoolProbe|TestEraCacheAcrossStarts|TestEraIdentity'— run 46465786079 ✅go test ./internal/e2e/ -race -shuffle=6839106235133155819 -count=3 -run '^TestTheEraIsProbedOnceAndRememberedAcrossDaemonRestarts$'— run 46465851274 ✅No quarantine, no seed pinning, no count reduction: the fix removes the born-dead transport at the seam where it is created.
{ "direct_parent": null, "links": [], "lineage": { "design": null, "roadmap_item": null, "priority": null }, "pm_meta": 1, "provenance": { "queue_id": null, "scheduled_start": null, "picked_up_at": null, "work_started_at": null, "created_at": "2026-11-30T16:54:28Z", "session_id": null, "lane": null, "host": "htch-runtime", "worktree": "/home/hatch/workspace/github-work/code-17226", "model": null, "lane_start_issues": [], "workspace_ref": { "kind": "worktree", "id": "/home/hatch/workspace/github-work/code-17226", "repo": "developing-today/code", "branch": "xaltha/17226-era-probe-race", "sha": "ff2c16d014d5c80827b5590deb69ce589f452a6c" }, "auth_subject": "xaltha", "stamped_by": "fleet 0.1.0 (native)" } }Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.