Mask errors from websocket being closed; closes pterodactyl/panel#2387

This commit is contained in:
Dane Everitt 2020-09-26 16:10:32 -07:00
parent 0b9ad3de05
commit 62d0c7fa24
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -134,7 +134,23 @@ func (h *Handler) SendJson(v *Message) error {
}
}
return h.unsafeSendJson(v)
if err := h.unsafeSendJson(v); err != nil {
// Not entirely sure how this happens (likely just when there is a ton of console spam)
// but I don't care to fix it right now, so just mask the error and throw a warning into
// the logs for us to look into later.
if errors.Is(err, websocket.ErrCloseSent) {
if h.server != nil {
h.server.Log().WithField("subsystem", "websocket").
WithField("event", v.Event).
Warn("failed to send event to websocket: close already sent")
}
return nil
}
return err
}
return nil
}
// Sends JSON over the websocket connection, ignoring the authentication state of the