Skip to content

TestRunServer_ContextCancelled races closed stdin against the cancelled context #8355

Closed

Description

@devantler

🤖 Generated by the Agentic Engineer

Evidence

TestRunServer_ContextCancelled (pkg/svc/mcp/server_additional_test.go) failed in 🧪 Test on #8354 at 2026-11-13 02:29Z (job 131631151600) with An error is expected but got nil. That PR changes only CI workflow steps and a workflow contract test, so the failure is not caused by it.

The test cancels the context and then calls RunServer, which serves over the process's standard input. When standard input is already at end of file, as it is in CI, the server can return nil from the closed input before it observes the cancelled context. Which one wins is a race, so the test passes or fails by timing.

Problem

A correct pull request goes red on an unrelated test, and scheduled agent runs cannot rerun a failed job (devantler-tech/monorepo#4428), so each occurrence costs a new commit and a full ~70-minute CI cycle.

Hypothesis and success signal

If the test controls the transport (for example an in-memory transport, or a stdin it owns that never reaches end of file) so the only way to stop is the cancelled context, it becomes deterministic. Success: go test -run TestRunServer_ContextCancelled -count=500 ./pkg/svc/mcp/ passes with standard input at end of file, and the test still fails if RunServer ignores a cancelled context.

Acceptance criteria

  • The test no longer depends on the state of the process's standard input.
  • A negative control shows it still catches a RunServer that ignores cancellation.
  • 500 repeated runs pass locally.

Activity

  1. added theissue type on Nov 13, 2026
  2. moved this to 📥 Backlog in 🌊 Project Boardon Nov 13, 2026
  3. added a commit that references this issue on Nov 13, 2026
  4. moved this from 📥 Backlog to 🏃🏻‍♂️ In Progress in 🌊 Project Boardon Nov 13, 2026
  5. self-assigned this
    on Nov 13, 2026
  6. moved this from 🏃🏻‍♂️ In Progress to 👀 In Review in 🌊 Project Boardon Nov 13, 2026
  7. moved this from 👀 In Review to ✅ Done in 🌊 Project Boardon Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Priority

None yet

Effort

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions