Skip to content

chore: avoid logging http.ErrAbortHandler panics #6686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore: avoid logging http.ErrAbortHandler panics
  • Loading branch information
deansheather committed Mar 21, 2023
commit b8c0d77e6d94217caeded796755228a2a6cf7582
8 changes: 7 additions & 1 deletion coderd/httpmw/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down