Skip to content

fix(test): StdioMcpTransport process tests — race against fast child …#46

Merged
Skobeltsyn merged 1 commit intomainfrom
fix/stdio-transport-test-flake
May 5, 2026
Merged

fix(test): StdioMcpTransport process tests — race against fast child …#46
Skobeltsyn merged 1 commit intomainfrom
fix/stdio-transport-test-flake

Conversation

@Skobeltsyn
Copy link
Copy Markdown
Contributor

…exit on Linux CI

Three tests in StdioMcpTransportForProcessTest spawned sh -c "printf ...; exit" without first reading from stdin. rpc() then writes the request to the child's stdin AFTER the child has already exited and closed the pipe → BrokenPipe IOException. macOS process startup is slow enough that the write usually wins the race; Linux CI (especially under Gradle 9.5's faster scheduling) loses it.

Fix: prefix each child's shell command with read req; so the child blocks on stdin until rpc()'s write arrives. Same response behaviour after; the read content is discarded.

Affected tests:

  • forProcess applies env map to the child process
  • forProcess applies workingDir to the child process (the one that surfaced)
  • forProcess pipes child stderr lines into stderrSink

…exit on Linux CI

Three tests in StdioMcpTransportForProcessTest spawned `sh -c "printf ...; exit"`
without first reading from stdin. rpc() then writes the request to the child's
stdin AFTER the child has already exited and closed the pipe → BrokenPipe
IOException. macOS process startup is slow enough that the write usually wins
the race; Linux CI (especially under Gradle 9.5's faster scheduling) loses it.

Fix: prefix each child's shell command with `read req;` so the child blocks
on stdin until rpc()'s write arrives. Same response behaviour after; the read
content is discarded.

Affected tests:
- forProcess applies env map to the child process
- forProcess applies workingDir to the child process  (the one that surfaced)
- forProcess pipes child stderr lines into stderrSink

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Skobeltsyn Skobeltsyn merged commit c012900 into main May 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant