Skip to content

Gracefully close websocket connections #3638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Address feedback around defer unlock
john-markham committed Apr 7, 2025
commit 91c086fd3ae85264a9e2bd7f24fa0d49672bcd21
3 changes: 1 addition & 2 deletions graphql/handler/transport/websocket.go
Original file line number Diff line number Diff line change
@@ -238,13 +238,12 @@

func (c *wsConnection) write(msg *message) {
c.mu.Lock()
defer c.mu.Unlock()
// don't write anything to a closed / closing connection
if c.serverClosed {
c.mu.Unlock()
return
}
c.handlePossibleError(c.me.Send(msg), false)
c.mu.Unlock()
}

func (c *wsConnection) run() {
@@ -548,7 +547,7 @@

closeTimeout := c.closeTimeout
if closeTimeout == 0 {
closeTimeout = time.Second * 3

Check failure on line 550 in graphql/handler/transport/websocket.go

GitHub Actions / golangci-lint (1.23)

ineffectual assignment to closeTimeout (ineffassign)
}
closeTimer := time.NewTimer(c.closeTimeout)