mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: avoid logging http.ErrAbortHandler panics (#6686)
This commit is contained in:
@ -15,7 +15,13 @@ func Recover(log slog.Logger) func(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
defer func() {
|
||||
r := recover()
|
||||
if r != nil {
|
||||
|
||||
// Reverse proxying (among other things) may panic with
|
||||
// http.ErrAbortHandler when the request is aborted. It's not a
|
||||
// real panic so we shouldn't log them.
|
||||
//
|
||||
//nolint:errorlint // this is how the stdlib does the check
|
||||
if r != nil && r != http.ErrAbortHandler {
|
||||
log.Warn(context.Background(),
|
||||
"panic serving http request (recovered)",
|
||||
slog.F("panic", r),
|
||||
|
Reference in New Issue
Block a user