mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-22 03:06:36 +03:00
app/vmauth: properly handle http.ErrAbortHandler panic
This panic can be raised by the reverseProxy on aborted request to the backend. So handle it (e.g. suppress) at reverseProxy.ServeHTTP call. Do not suppress the panic at lib/httpserver generic HTTP handler, since it may result in an inconsistent state left after the panicking handler. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1353
This commit is contained in:
@@ -212,9 +212,7 @@ func handlerWrapper(s *server, w http.ResponseWriter, r *http.Request, rh Reques
|
||||
// The following recover() code works around this by explicitly stopping the process after logging the panic.
|
||||
// See https://github.com/golang/go/issues/16542#issuecomment-246549902 for details.
|
||||
defer func() {
|
||||
// need to check for abortHandler
|
||||
// https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1353
|
||||
if err := recover(); err != nil && err != http.ErrAbortHandler {
|
||||
if err := recover(); err != nil {
|
||||
buf := make([]byte, 1<<20)
|
||||
n := runtime.Stack(buf, false)
|
||||
fmt.Fprintf(os.Stderr, "panic: %v\n\n%s", err, buf[:n])
|
||||
|
||||
Reference in New Issue
Block a user