Repository navigation
Conversation
WriteMessage was called with no deadline while control frames already used wsWriteWait. Once a peer stops reading and the socket buffers fill, that call blocks indefinitely — and because the ping ticker shares the same select, pings stop going out too, so neither end concludes the connection is dead. The read side has wsPongWait for exactly this case; the write side had nothing. A write that failed partway leaves an incomplete frame on the wire, so the connection is now closed rather than reused. The error still reaches the waiting caller first. wsWriteWait becomes a var so the test can shorten it. Without the deadline that test hangs until its own 30s guard; with it, it finishes in 250ms.
bodyclose flags the discarded *http.Response from the websocket dial: the handshake response carries a body that has to be closed even when the upgrade succeeded. Claude-Session: https://claude.ai/code/session_01G2XvQ5dvdm32wf7K6mgdds
|
This is far outside my go knowledge but my 🤖 said this: 1. On control-pool connections, the write error still ends in a permanent hangThis is the main one. When the sprite supports control connections — the default path in func (c *wsCmd) readMessage() (messageType int, data []byte, err error) {
if c.usingControl && c.controlConn != nil {
select {
case msg := <-c.controlConn.readCh:
case <-c.ctx.Done():
}
}With the new
So on the control path this converts "hang with no error" into "the caller gets an error, then case <-c.controlConn.closedCh:
return 0, nil, errors.New("control connection closed")The hang itself is pre-existing — any death of the control socket triggers it — but this PR adds a new and much more reachable trigger, and it's the difference between the fix working and not working on the default code path. 2.
|
wsAdapter.writeLoopcallsWriteMessagewith no deadline, while control frames in the same loop already usewsWriteWait:Once a peer stops reading and the socket buffers fill, that call blocks indefinitely. Two things follow:
WriteRawwaits forever.select, so a wedged write silences the keepalive, and neither end ever concludes the connection is dead.The read side is already defended against exactly this —
wsPongWait, reset on pong, ping and any successful read. The write side had nothing.Why this matters in practice
An interactive session can go half-open (laptop sleeps, NAT drops the mapping, network changes) and hang indefinitely with no timeout and no error. Keystrokes stop arriving, nothing is reported, and the only way out is killing the client from another terminal. This is one of the paths that can produce that, and it's the one where the connection is provably unable to report itself dead.
Change
wsWriteWaitbecomes avarso the test can shorten it.Test
A server that upgrades and then never reads. The client writes until the buffers fill.