Skip to content

Commit eea54be

Browse files
fixes
1 parent 9618f7e commit eea54be

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

graphql/websocket.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ const (
4545
type webSocketClient struct {
4646
Dialer Dialer
4747
header http.Header
48-
endpoint string
4948
conn WSConn
5049
connParams map[string]interface{}
5150
errChan chan error
5251
subscriptions subscriptionMap
52+
endpoint string
5353
isClosing bool
5454
sync.Mutex
5555
}
@@ -105,9 +105,10 @@ func (w *webSocketClient) waitForConnAck() error {
105105

106106
func (w *webSocketClient) handleErr(err error) {
107107
w.Lock()
108-
isClosing := w.isClosing
109-
w.Unlock()
110-
if !isClosing {
108+
defer w.Unlock()
109+
if !w.isClosing {
110+
// Send while holding lock to prevent Close() from closing
111+
// the channel between our check and our send
111112
w.errChan <- err
112113
}
113114
}

0 commit comments

Comments
 (0)