panicparse
panicparse copied to clipboard
http.Serve stack printed only after 2nd panic
env
go version go1.24.0 darwin/arm64 fish, version 4.0.0 panicparse v2.4.0
steps to reproduce
setup a server like this
package main
import (
"log"
"net/http"
"regexp"
)
func main() {
s := &http.Server{Addr: ":8888", Handler: http.HandlerFunc(handle)}
log.Fatal(s.ListenAndServe())
}
func handle(http.ResponseWriter, *http.Request) {
regexp.MustCompile("p([a-z]+ch")
}
launch the server with
go run . &| pp
in other console execute
curl localhost:8888
then the server only prints
2025/03/01 20:16:26 http: panic serving [::1]:50210: regexp: Compile(`p([a-z]+ch`): error parsing regexp: missing closing ): `p([a-z]+ch`
if we execute curl again only then we get the 1st parsed panic followed by the 2nd "http: panic serving" log without stack
To see all goroutines, visit https://github.com/maruel/panicparse#gotraceback
1: running [Created by http.(*Server).Serve in goroutine 1 @ server.go:3454]
http server.go:1947 (*conn).serve.func1()
panic.go:787 panic(any{0x1006a8180, 0x1400009e2e0})
regexp regexp.go:313 MustCompile(string(0x10061742e, len=10))
main main.go:15 handle(ResponseWriter{0x140000fdb78, 0x1005b216c}, *Request(0x1400009a128))
http server.go:2294 HandlerFunc.ServeHTTP(ResponseWriter(0x0), *Request(#2), 0x140000fdb60)
http server.go:3301 serverHandler.ServeHTTP(ResponseWriter{0x140000a3200}, *Request(#1), #2, 0x1)
http server.go:2102 (*conn).serve(*conn(0x140000de240), Context{0x10070f0a8, 0x140000a3110})
2025/03/01 20:18:03 http: panic serving [::1]:50212: regexp: Compile(`p([a-z]+ch`): error parsing regexp: missing closing ): `p([a-z]+ch`