Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Original stacktrace info are dismissed and ignored on panic #70

Open
HosseyNJF opened this issue Sep 11, 2024 · 0 comments
Open

Original stacktrace info are dismissed and ignored on panic #70

HosseyNJF opened this issue Sep 11, 2024 · 0 comments

Comments

@HosseyNJF
Copy link

HosseyNJF commented Sep 11, 2024

Related: #36

When an endpoint uses the timeout wrapper and panics, the stacktrace shown in the logs won't contain any reference to the actual line that caused the panic. I believe it happens because the controller code runs in a goroutine and thus the library can't know about where the panic originally happened.

Stacktrace without timeout wrapper:

net/http.(*conn).serve.func1()
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/net/http/server.go:1873 +0xb0
panic({0x105fb29a0?, 0x106809e10?})
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/runtime/panic.go:920 +0x26c
github.com/getsentry/sentry-go/gin.(*handler).recoverWithSentry(0x140002a20c0, 0x104f0a9b4?, 0x140000fe200)
        ~/go/pkg/mod/github.com/getsentry/sentry-go@v0.23.0/gin/sentrygin.go:91 +0xf4
panic({0x105fb29a0?, 0x106809e10?})
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/runtime/panic.go:914 +0x218
project/dispatch.(*Subscriber).CreateBatch(0x14000254640, {0x1400047c500, 0x1c})
        ~/project/dispatch/subscriber.go:182 +0x38
project/dispatch.(*Submitter).Submit(0x14000278200, {{0x106118930, 0x14000215290}, 0x14000254640, {0x140002a2cc0, 0x5}, {0x140005302bd, 0xa}})
        ~/project/dispatch/submit.go:158 +0x970
project/api/controller.(*Controller).HandleSendingToSubscription(0x140003ca100, 0x140000fe100)
        ~/api/controller/subscription.go:118 +0x80c
github.com/gin-gonic/gin.(*Context).Next(...)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173
project/api/middleware.AuthTokenMiddleware(0x140000fe100)
        ~/project/api/middleware/auth.go:42 +0x130
github.com/gin-gonic/gin.(*Context).Next(0x140000fe100)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 +0x3c
project/api/router.(*Router).Serve.LoggingMiddleware.func2(0x140000fe100)
        ~/project/api/middleware/log.go:14 +0x38
github.com/gin-gonic/gin.(*Context).Next(0x140000fe100)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 +0x3c
project/api/router.(*Router).Serve.Recover.func1(0x140000fe100?)
        ~/project/api/middleware/recover.go:25 +0x38
github.com/gin-gonic/gin.(*Context).Next(...)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173
github.com/getsentry/sentry-go/gin.(*handler).handle(0x140002a20c0, 0x140000fe100)
        ~/go/pkg/mod/github.com/getsentry/sentry-go@v0.23.0/gin/sentrygin.go:76 +0x3c0
github.com/gin-gonic/gin.(*Context).Next(...)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0x140002371e0, 0x140000fe100)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/gin.go:616 +0x524
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0x140002371e0, {0x106116600?, 0x140004520e0}, 0x140000fe000)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/gin.go:572 +0x1a0
net/http.serverHandler.ServeHTTP({0x106112a20?}, {0x106116600?, 0x140004520e0?}, 0x6?)
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/net/http/server.go:2943 +0xbc
net/http.(*conn).serve(0x140001d6240, {0x106118930, 0x14000214540})
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/net/http/server.go:2014 +0x518
created by net/http.(*Server).Serve in goroutine 1
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/net/http/server.go:3091 +0x4cc

(Notice the lines starting with ~/project)

Stacktrace with timeout wrapper:

runtime error: invalid memory address or nil pointer dereference
goroutine 14 [running]:
net/http.(*conn).serve.func1()
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/net/http/server.go:1873 +0xb0
panic({0x101202620?, 0x101a2ddc0?})
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/runtime/panic.go:920 +0x26c
github.com/gin-contrib/timeout.New.func1(0x14000030000)
        ~/go/pkg/mod/github.com/gin-contrib/timeout@v0.0.3/timeout.go:63 +0x6dc
github.com/gin-gonic/gin.(*Context).Next(...)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173
project/api/middleware.AuthTokenMiddleware(0x14000030000)
        ~/project/api/middleware/auth.go:42 +0x130
github.com/gin-gonic/gin.(*Context).Next(0x14000030000)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 +0x3c
project/api/router.(*Router).Serve.LoggingMiddleware.func2(0x14000030000)
        ~/project/api/middleware/log.go:14 +0x38
github.com/gin-gonic/gin.(*Context).Next(0x14000030000)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 +0x3c
project/api/router.(*Router).Serve.Recover.func1(0x1400048c9a8?)
        ~/project/api/middleware/recover.go:25 +0x38
github.com/gin-gonic/gin.(*Context).Next(...)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0x140004b2820, 0x14000030000)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/gin.go:616 +0x524
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0x140004b2820, {0x10135f8b0?, 0x14000024000}, 0x140004ca500)
        ~/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/gin.go:572 +0x1a0
net/http.serverHandler.ServeHTTP({0x10135bea0?}, {0x10135f8b0?, 0x14000024000?}, 0x6?)
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/net/http/server.go:2943 +0xbc
net/http.(*conn).serve(0x140000d61b0, {0x101361b60, 0x14000686360})
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/net/http/server.go:2014 +0x518
created by net/http.(*Server).Serve in goroutine 1
        /opt/homebrew/Cellar/go@1.21/1.21.13/libexec/src/net/http/server.go:3091 +0x4cc

In this stacktrace, only the middlewares of my project are present and not the real source of panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant