rpc: use library Close helper for websocket disconnect#20913
Merged
Conversation
Replace the manual goroutine + timer pattern in wsConnAdapter.Close with a direct call to coder/websocket Conn.Close(StatusNormalClosure, ""), which already performs the close handshake with bounded internal timeouts (5s write, 5s read). Follow-up to #20788. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Giulio2002
approved these changes
Apr 29, 2026
Giulio2002
left a comment
Contributor
There was a problem hiding this comment.
LGTM — small, obvious cleanup: use the websocket library's close helper directly instead of duplicating custom close-handshake logic here.
lupin012
added a commit
that referenced
this pull request
Apr 29, 2026
#20913 replaced the two-goroutine async close with a direct conn.Close() call, noting that coder/websocket already handles the close handshake with bounded internal timeouts (5s write, 5s read). Align our branch to avoid re-introducing the goroutines when merging. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #20788. Address review feedback from @anacrolix:
The
coder/websocketConn.Close(code, reason)method already performs the close handshake with bounded internal timeouts (5s write, 5s read), so the manual goroutine + timer plumbing inwsConnAdapter.Closeis redundant. Replace it with a direct call.The existing
TestWebsocketServerGracefulClosetest still passes — clients see a cleanStatusNormalClosure(1000) instead ofStatusAbnormalClosure(1006).Test plan
go test ./rpc/ -run Websocket— all passmake lint— clean🤖 Generated with Claude Code