From b8ea88618dceecbfec37c451b88d8153e7d33d67 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sat, 29 May 2021 17:00:31 +0200 Subject: [PATCH] recoverer: don't recover http.ErrAbortHandler This error is generally used to abort a request while streaming a response so it should not be recovered otherwise the request is not aborted and the client does not detect the error --- middleware/recoverer.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/middleware/recoverer.go b/middleware/recoverer.go index 785b18c5..4d36937b 100644 --- a/middleware/recoverer.go +++ b/middleware/recoverer.go @@ -21,7 +21,12 @@ import ( func Recoverer(next http.Handler) http.Handler { fn := func(w http.ResponseWriter, r *http.Request) { defer func() { - if rvr := recover(); rvr != nil && rvr != http.ErrAbortHandler { + if rvr := recover(); rvr != nil { + if rvr == http.ErrAbortHandler { + // we don't recover http.ErrAbortHandler so the response + // to the client is aborted + panic(rvr) + } logEntry := GetLogEntry(r) if logEntry != nil {