Repository navigation
mcpx/testsupport: replay Send honours its context (#17221 slice 3) - #17234
Merged
Merged
Conversation
…lice 3) Failing-first: ReplayTransport.Send ignores its context entirely and cond-waits on the recorded interleave, so a stalled interleave cannot be cancelled by the caller's deadline — the shape behind the ubuntu stress failure of TestReplayTruncatedTraceFailsTheCall (10.01s, context deadline exceeded, run 46433738642). The cases name the context as oracle: deadline while waiting, cancel while waiting, expiry does not poison the replay, and a waiting Send still completes when the interleave advances.
ReplayTransport.Send dropped its context and waited on a sync.Cond for the recorded interleave; nothing could cancel that wait, so a stalled interleave held the caller's goroutine past its deadline — Send is synchronous, and the client reaches its ctx select only after Send returns (mcpclient's transport contract, stated in TestAHungServerDoesNotOutliveTheCallTimeout). Replace the cond with a broadcast wake channel (closed and replaced on every state change). Send now selects on the wake channel and ctx.Done while waiting and returns the context's error; expiry records no divergence, so the replay is not poisoned and can still be driven to completion. Recv, Close and divergence wake through the same channel with unchanged behaviour.
|
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.
Refs #17221 (slice 3 of 3 — the replay leg; slice 1 is lane 0900-N's bin-args timeouts, slice 2 the era-probe race, both tracked on the issue).
Defect
ReplayTransport.Senddropped itscontext.Context(_ context.Context) and waited on async.Condfor the recorded interleave. Nothing could cancel that wait. Send is synchronous —mcpclient'scallreaches its ownctx.Doneselect only after Send returns — so a stalled interleave held the caller's goroutine past its deadline. That is the transport contract every other Send honours (stated in mcpclient'sTestAHungServerDoesNotOutliveTheCallTimeout), and the shape behind the ubuntu stress failure in run 46433738642:TestReplayTruncatedTraceFailsTheCall's first call sat out its whole 10s context (replay_test.go:332,context deadline exceeded) under-race -shuffle 6839106235133155819 -count=3.Replay is the only Send whose blocking is a peer-condition wait rather than I/O (checked: HTTP honours ctx; stdio/record/sse/supervised perform writes or forward), so the fix is scoped to it.
Fix
Replace the cond with a broadcast wake channel (closed and replaced under the mutex on every state change). Send selects on the wake channel and
ctx.Done()while waiting and returns the context's error; expiry records no divergence, so the replay is not poisoned and can still be driven to completion. Recv/Close/divergence wake through the same channel with unchanged behaviour.Tests (failing-first, per the mcpx testing doctrine)
New
replay_ctx_test.go, oracle = the context, not the clock:context.DeadlineExceededcontext.CanceledFinishpasses)Failing-first evidence: run 46447246624 (fleet-command, exact head bb242a9, tests only) — both context cases FAIL with "Send outlived its context while waiting on the interleave".
Verification of this head: run 46448919826 (fleet-command) —
go test ./internal/testsupport/ -run 'TestReplay|TestRecordReplay|TestClientTraceCapture|TestDialCapture' -race -shuffle=on -count=5plus a full-package-count=1pass; conclusion recorded on #17221.{ "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-30T15:19:41Z", "session_id": null, "lane": null, "host": "htch-runtime", "worktree": "/home/hatch", "model": null, "lane_start_issues": [], "workspace_ref": { "kind": "worktree", "id": "/home/hatch", "repo": "developing-today/code", "branch": "main", "sha": "a5c7d0c9db1fd1918e903ac85cd57eb87faf2620" }, "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.