fix(coderd/httpapi): CloseRead on test conns to ensure pings pong (#25184)

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)
This commit is contained in:
Cian Johnston
2026-05-14 13:54:59 +01:00
committed by GitHub
parent f3e90b334d
commit da2fa082bb
@@ -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")