From 803daaa8b7dd2dbabea2192c6b734251c30dc841 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Thu, 18 Jun 2026 10:28:17 +0200 Subject: [PATCH] fix(coderd/x/chatd): deflake TestStreamPartsDialerDialsPartsEndpoint (#26504) Closes https://github.com/coder/internal/issues/1601. Fixes a stream parts WebSocket close race. If the peer closed first, the session read loop could close the connection before `StreamPartsSession.Close()` ran, causing cleanup to return a wrapped `net.ErrClosed`. The fix treats expected transport close errors as successful cleanup. --- coderd/x/chatd/stream_parts_transport.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/coderd/x/chatd/stream_parts_transport.go b/coderd/x/chatd/stream_parts_transport.go index 461a950f6b..04544cf741 100644 --- a/coderd/x/chatd/stream_parts_transport.go +++ b/coderd/x/chatd/stream_parts_transport.go @@ -214,6 +214,9 @@ func (s *streamPartsTransportSession) Close() error { s.closeOnce.Do(func() { s.cancel() s.closeErr = s.transport.Close() + if streamPartsExpectedTransportClose(s.closeErr) { + s.closeErr = nil + } }) return s.closeErr }