Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| // Close the old socket before reconnecting. Otherwise it stays open | ||
| // until the server's idle check notices it is dead. | ||
| c.stateMu.Lock() | ||
| _ = c.conn.Close() |
There was a problem hiding this comment.
Can we add to this comment that it's deliberately not a 1000 close? On the server (handleSocketClose in core's websocketProxy.ts) a 1000 deletes the session and anything else keeps it for the reconnect. Would be easy for someone to "tidy" this into a ws.CloseMessage later and break reconnects.
Generated by Claude Code
There was a problem hiding this comment.
@alexluong rather than a comment I've pushed 92f5223 to this branch. The close is now closeForReconnect(), next to Stop(), so the two exits read as a pair. TestReadTimeoutClosesSocket also asserts the server sees a 1006, so if someone swaps in a 1000 close the test fails rather than reconnects quietly breaking.
Generated by Claude Code
| defaultPongWait = 10 * time.Second | ||
| // defaultPongWait leaves room for a few late pongs (slow network, busy | ||
| // server) before the connection is treated as dead. | ||
| defaultPongWait = 30 * time.Second |
There was a problem hiding this comment.
Did you consider 20s? With 10s pings that still covers one pong up to ~10s late.
The server never pings the CLI and only sweeps idle sockets every 30s, so when a connection dies silently it's the CLI's reconnect that stops events being sent to the dead socket. Those events end up as TIMEOUT. 30s means up to ~32s of that vs ~22s with 20s. Not a blocker if you think the extra tolerance is worth it.
Generated by Claude Code
Move the raw socket close used before reconnecting into closeForReconnect, next to Stop, so the two exits read as a pair: Stop sends a 1000 close and the server deletes the session; closeForReconnect sends no close frame, so the server sees 1006 and keeps the session for the reconnect. TestReadTimeoutClosesSocket now asserts the server sees an abnormal close, so swapping in a clean close fails the test rather than breaking reconnects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRc1axJoxMwiK5nm2q7YqP
hookdeck listendrops a healthy connection whenever the server's reply to a ping (pong) is more than about a second late. Users on slower or busier networks then see "Connection lost, reconnecting..." every few minutes.Why: the client pings every 9s and drops the connection if no pong arrives within 10s of the previous one. That leaves about 1s of slack:
Changes (
pkg/websocket/client.go):Tests: a busy connection with late pongs stays up; the socket closes after a read timeout; new defaults. All three fail on the old code.
🤖 Generated with Claude Code