From da2fa082bbcb8ec49271587303a6f82e779887a7 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Thu, 14 May 2026 13:54:59 +0100 Subject: [PATCH] fix(coderd/httpapi): CloseRead on test conns to ensure pings pong (#25184) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `websocketPair` test helper was not calling `CloseRead` on either side of the connection. Without `CloseRead`, the websocket library does not process control frames (ping/pong), so the heartbeat tests were passing only because no pings had yet failed, not because pings were actually succeeding. Add `CloseRead` on both the client and server connections so that pong frames are delivered in response to pings. Split out from #25012. > 🤖 Generated with [Coder Agents](https://coder.com) --- coderd/httpapi/websocket_internal_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coderd/httpapi/websocket_internal_test.go b/coderd/httpapi/websocket_internal_test.go index 13f242fdc8..9736292e9d 100644 --- a/coderd/httpapi/websocket_internal_test.go +++ b/coderd/httpapi/websocket_internal_test.go @@ -38,12 +38,14 @@ func websocketPair(ctx context.Context, t *testing.T) *websocket.Conn { //nolint:bodyclose clientConn, _, err := websocket.Dial(ctx, srv.URL, nil) require.NoError(t, err) + _ = clientConn.CloseRead(ctx) // Needed to handle pings/pongs. t.Cleanup(func() { _ = clientConn.Close(websocket.StatusNormalClosure, "test cleanup") }) select { case sc := <-serverConnCh: + _ = sc.CloseRead(ctx) // Needed to handle pings/pongs. return sc case <-ctx.Done(): t.Fatal("timed out waiting for server websocket accept")