From e738a21a2ab57a1b0526c1b2ddd8a599d273c70e Mon Sep 17 00:00:00 2001 From: Wicliff Wolda Date: Thu, 1 Oct 2026 15:30:22 +0200 Subject: [PATCH] test(handler): stop asserting on an upstream connection the proxy abandons TestRelayRoutes fails intermittently on CI with "write: connection reset by peer" at the upstream handler's final Flush, on /hex/packages/demo and /gem/info/demo. Those two routes are the only ones in the table that fan out a second upstream request: with cooldown enabled, the hex and gem handlers fetch version timestamps concurrently with the artifact. The test server answers that sidecar request with the same 64 KiB chunked 502, but the handler returns as soon as it sees a non-200 and closes the body unread, so the proxy drops the connection while the test server is still writing to it. Whether the reset lands before or after the Flush is a scheduling race, which is why it only surfaces on loaded runners. The flush error says nothing about the response under test, which is asserted on the downstream side, so stop reporting it. Co-Authored-By: Claude Opus 5 (1M context) --- internal/handler/relay_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/handler/relay_test.go b/internal/handler/relay_test.go index 5200ffba..67af121c 100644 --- a/internal/handler/relay_test.go +++ b/internal/handler/relay_test.go @@ -82,9 +82,11 @@ func testRelayRoute(t *testing.T, route string, truncated bool) { if !truncated { _, _ = fmt.Fprint(rw, "0\r\nX-Checksum: verified\r\nX-Late: discovered-at-eof\r\nX-Private: still-secret\r\n\r\n") } - if err := rw.Flush(); err != nil { - t.Error(err) - } + // Two of these routes fan out a second upstream request for cooldown + // timestamps and abandon its body on a non-200, so this may be writing to + // a connection the proxy has already dropped. What the proxy made of the + // response under test is asserted downstream. + _ = rw.Flush() })) defer upstream.Close() proxy := testProxy()