Skip to content

Commit 6e43c31

Browse files
committed
Handle ws upgrade errors more correctly
1 parent 0e65da3 commit 6e43c31

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func (s *RPCServer) handleWS(ctx context.Context, w http.ResponseWriter, r *http
6767

6868
c, err := upgrader.Upgrade(w, r, nil)
6969
if err != nil {
70-
log.Error(err)
71-
w.WriteHeader(500)
70+
log.Errorw("upgrading connection", "error", err)
71+
// note that upgrader.Upgrade will set http error if there is an error
7272
return
7373
}
7474

@@ -80,7 +80,7 @@ func (s *RPCServer) handleWS(ctx context.Context, w http.ResponseWriter, r *http
8080
}).handleWsConn(ctx)
8181

8282
if err := c.Close(); err != nil {
83-
log.Error(err)
83+
log.Errorw("closing websocket connection", "error", err)
8484
return
8585
}
8686
}

0 commit comments

Comments
 (0)