log context cancellation as debug instead of error (#3268)

This commit is contained in:
thiagomedina 2025-10-06 21:01:10 -03:00 committed by GitHub
parent 1e71536171
commit e53fcbb069
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -17,6 +17,8 @@ limitations under the License.
package network
import (
"context"
"errors"
"net/http"
"os"
@ -29,6 +31,10 @@ import (
// Deprecated: Use handler.Error instead.
func ErrorHandler(logger *zap.SugaredLogger) func(http.ResponseWriter, *http.Request, error) {
return func(w http.ResponseWriter, req *http.Request, err error) {
if errors.Is(err, context.Canceled) {
logger.Debugw("request context canceled", zap.Error(err))
return
}
ss := readSockStat(logger)
logger.Errorw("error reverse proxying request; sockstat: "+ss, zap.Error(err))
http.Error(w, err.Error(), http.StatusBadGateway)