From d2415e54db2617848cd2d0ac194b4c722c93fca0 Mon Sep 17 00:00:00 2001 From: adshield-joon <96225028+adshield-joon@users.noreply.github.com> Date: Thu, 2 Feb 2023 15:31:58 -0500 Subject: [PATCH] Trea http.ErrAbortHandler as broken pipe ``` ErrAbortHandler is a sentinel panic value to abort a handler. While any panic from ServeHTTP aborts the response to the client, panicking with ErrAbortHandler also suppresses logging of a stack trace to the server's error log. ``` - CC - #1714 - similar to https://github.com/gorilla/handlers/pull/159/files - Other PR: https://github.com/gin-gonic/gin/pull/2590 --- recovery.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recovery.go b/recovery.go index 2955c03a..7d3be93e 100644 --- a/recovery.go +++ b/recovery.go @@ -69,6 +69,9 @@ func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc { } } } + if errors.Is(err, http.ErrAbortHandler) { + brokenPipe = true + } if logger != nil { stack := stack(3) httpRequest, _ := httputil.DumpRequest(c.Request, false)