From 65144c7b26d06161202b7e5fa73ca071b13206ca Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Mon, 4 Oct 2021 07:31:43 +0200 Subject: [PATCH] Prevent context-canceled errors from logging --- auth/handlers/handle_oauth2.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/auth/handlers/handle_oauth2.go b/auth/handlers/handle_oauth2.go index dc1a31ded..457409ebd 100644 --- a/auth/handlers/handle_oauth2.go +++ b/auth/handlers/handle_oauth2.go @@ -167,7 +167,18 @@ func (h AuthHandlers) oauth2Token(req *request.AuthReq) (err error) { func (h AuthHandlers) oauth2Info(w http.ResponseWriter, r *http.Request) { ti, err := h.OAuth2.ValidationBearerToken(r) + if err != nil { + if errors.Is(err, context.Canceled) { + // Gracefully handle request cancellation + // + // This happens during the login procedure when browser is + // sent through a couple of quick redirects that can + // terminate requests + w.WriteHeader(http.StatusNoContent) + return + } + var ( data = make(map[string]interface{}) code int