Plans to merge ErrAbortHandler Fix? #4408
Replies: 1 comment
-
|
$(cat <<'ENDOFBODY' But Gin's recovery middleware catches it like any other panic, writes a 500 response, and completely defeats the purpose. By the time Workaround until this is fixed — wrap the default recovery with a check: func CustomRecovery() gin.HandlerFunc {
return func(c *gin.Context) {
defer func() {
if err := recover(); err != nil {
// Let ErrAbortHandler do its job
if err == http.ErrAbortHandler {
panic(http.ErrAbortHandler)
}
// Handle everything else normally
c.AbortWithStatus(http.StatusInternalServerError)
}
}()
c.Next()
}
}r := gin.New()
r.Use(CustomRecovery()) // instead of gin.Recovery()This re-panics with Honestly, this should be a one-line fix in Gin's recovery middleware — just check |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Been watching for this MR to go in for a while but haven't seen any traction on it being reviewed. Do the maintainers have intentions of getting this one in on an upcoming release?
#4336
I'm using the recovery middleware in an AI Chat backend and this panic gets printed pretty often when the client cancels a chat stream in progress. It would help clean up our logs quite a bit!
Beta Was this translation helpful? Give feedback.
All reactions