Make reconnect-retry HTTP transport test shutdown deterministic - #9725
Conversation
Address review feedback on #9667. The previous shutdown was racy: starting srv.Close() in a goroutine did not guarantee the listener or current keep-alive connection was closed before sendHTTPRequest issued its retry, so the retry could reach the handler, get another 404, and make require.Error fail intermittently. Make the transition deterministic: on the reconnect initialize, set Connection: close on the response and synchronously close srv.Listener before the handler returns so the retry cannot reuse or reconnect to the server. Normal server cleanup is deferred. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 16dda201-99df-4ddf-8139-e4ee11ef18be
There was a problem hiding this comment.
Pull request overview
Makes the reconnect-retry HTTP transport test deterministic.
Changes:
- Closes the test listener synchronously after reconnect.
- Forces the active HTTP connection to close before retry.
- Defers full server cleanup.
Show a summary per file
| File | Description |
|---|---|
internal/mcp/http_transport_test.go |
Removes racy asynchronous shutdown from the reconnect test. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Medium
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS
References: §29779721591 Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "host.docker.internal"See Network Configuration for more information.
|
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Notes:
Overall: PASS References: §29779721418 Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS Full ReportPart A — MCP Reads ✅
Part B — MCP Writes ✅All 7 write tools returned gateway error Part C — CLI Reads ✅
Part D — CLI REST Writes ✅All 6 Part E — GraphQL Mutations ✅All 3 References: §29779721703
|
Summary
Addresses the review feedback on #9667 (which was merged before the feedback could be applied).
The Copilot reviewer flagged
TestSendHTTPRequest_ReconnectSucceedsButRetryFailsininternal/mcp/http_transport_test.goas racy:Fix
Following the reviewer's suggestion, the teardown is now deterministic. On the reconnect (second)
initializeresponse the handler:Connection: closeso the client cannot reuse the keep-alive connection for the retry.srv.Listenerbefore returning so the retrytools/listrequest cannot reconnect.srv.Close()itself can't be called synchronously inside the handler (it blocks on the in-flight connection), so only the listener is closed inline and full server cleanup is deferred. The now-unusedcloseAfterReconnectchannel and thego srv.Close()goroutine are removed.Verification
-count=50) and 20× under-race.make agent-finishedpasses (format, build, lint, all Go tests, Rust guard tests).