fix(cli): serialize mcp_http tests - #226
Conversation
The 4 async HTTP transport tests in `crates/plumb-cli/tests/mcp_http.rs` each call `reserve_port()` which binds a TCP listener on port 0, reads back the OS-assigned port, and drops the listener before spawning a child process to bind it. The drop-then-bind window is a TOCTOU race — under parallel test execution the kernel can hand the same port to two concurrent reservations, causing the second child to fail with "Connection reset by peer" (most often surfacing on `http_transport_rejects_invalid_bearer_token`). Annotate the 4 async tests with `#[serial_test::serial(mcp_http)]` so they serialize against each other while non-HTTP tests still run in parallel. The named group keeps the blast radius minimal. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
I now have all the context needed to write the full review. PR #226 —
|
Summary
crates/plumb-cli/tests/mcp_http.rseach callreserve_port(), which binds a TCP listener on port 0, reads back the OS-assigned port, drops the listener, then spawns a child to re-bind it. The drop-then-bind window is a TOCTOU race; under parallel execution the kernel can hand the same port to two reservations and the loser surfaces "Connection reset by peer" (most often onhttp_transport_rejects_invalid_bearer_token).serial_test = "3"to[workspace.dependencies]and theplumb-cli[dev-dependencies].#[tokio::test]HTTP fn with#[serial_test::serial(mcp_http)]so HTTP tests serialize against each other while non-HTTP tests stay parallel.Test plan
cargo test -p plumb-cli --test mcp_http— 6 passed locallycargo fmt --all -- --checkcargo clippy -p plumb-cli --tests -- -D warnings🤖 Generated with Claude Code