Skip to content

Commit 8aae0b6

Browse files
authored
chore: avoid logging http.ErrAbortHandler panics (#6686)
1 parent 4bf012c commit 8aae0b6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

coderd/httpmw/recover.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ func Recover(log slog.Logger) func(h http.Handler) http.Handler {
1515
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1616
defer func() {
1717
r := recover()
18-
if r != nil {
18+
19+
// Reverse proxying (among other things) may panic with
20+
// http.ErrAbortHandler when the request is aborted. It's not a
21+
// real panic so we shouldn't log them.
22+
//
23+
//nolint:errorlint // this is how the stdlib does the check
24+
if r != nil && r != http.ErrAbortHandler {
1925
log.Warn(context.Background(),
2026
"panic serving http request (recovered)",
2127
slog.F("panic", r),

0 commit comments

Comments
 (0)