[overlays] Fix: Do not spam logs with errors when overlay reloaded

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-12-24 14:28:07 +01:00
parent eb02858280
commit fa9f5591f6
Signed by: luzifer
SSH key fingerprint: SHA256:/xtE5lCgiRDQr8SLxHMS92ZBlACmATUmF1crK16Ks4E

View file

@ -315,10 +315,18 @@ func handleSocketSubscription(w http.ResponseWriter, r *http.Request) {
return return
case err := <-errC: case err := <-errC:
if err != nil { var cErr *websocket.CloseError
logger.WithError(err).Error("Message processing caused error") switch {
case err == nil:
// We use nil-error to close the connection
case errors.As(err, &cErr) && websocket.IsCloseError(cErr, websocket.CloseNormalClosure, websocket.CloseGoingAway):
// We don't need to log when the remote closes the websocket gracefully
default:
logger.WithError(err).Error("message processing caused error")
} }
return // We use nil-error to close the connection return // All errors need to quit this function
case msg := <-sendMsgC: case msg := <-sendMsgC:
if !isAuthorized { if !isAuthorized {