Skip to content

Commit

Permalink
Catch panics on hijjacked connection
Browse files Browse the repository at this point in the history
Catch all panics on hijacked websocket connection so that any middleware
that handles panics does not write to the connection.
  • Loading branch information
Dennor committed Dec 22, 2020
1 parent 95293b4 commit 264cd04
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/handlers/subscription_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {

result := graphql.Do(params)
if sub, ok := result.Extensions["subscriptionBlocking"].(router.BlockingSubscriptionPayload); ok && len(result.Errors) == 0 {
defer func() {
if r := recover(); r != nil {
klog.Error(r)
}
}()
conn, err := h.upgrader.Upgrade(rw, req, nil)
if err != nil {
klog.Error(err.Error())
Expand Down

0 comments on commit 264cd04

Please sign in to comment.