-
Notifications
You must be signed in to change notification settings - Fork 217
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
Stack trace has confusing top frame when using sentry.CurrentHub().Recover(err) #741
Comments
Here is an example exception: https://fancy-bits-llc.sentry.io/issues/3485598464/ What does the recover handler look like in your example? |
https://github.com/getsentry/sentry-go/blob/master/gin/sentrygin.go#L94 The issue you linked uses Go SDK 0.13.0 btw. |
Ah, you are correct. Here is one from the 0.25.0 SDK: https://fancy-bits-llc.sentry.io/issues/4575378790/ |
So to confirm, the panic stems from |
Yes. Line 341 of processor.go is:
from the above example recover block. |
Your repro doesn't properly reproduce the issue because you are relying on the Lines 323 to 327 in 8f8897d
If you try to reproduce this in a separate repo that contains its own |
So I did package main
import (
"log"
"time"
"github.com/getsentry/sentry-go"
)
func main() {
sentry.Init(sentry.ClientOptions{
Dsn: "<DSN>",
Debug: true,
AttachStacktrace: true,
})
doStuff()
defer sentry.Flush(2 * time.Second)
}
func doStuff() {
defer func() {
if err := recover(); err != nil {
log.Printf("[ERR] Error: %v", err)
sentry.CurrentHub().Recover(err)
}
}()
doMoreStuff()
}
func doMoreStuff() {
panic("oh no")
} and got https://sentry-sdks.sentry.io/share/issue/fe6200a9013b4c65802251ee877b5d97/. Hmmm, we could do some trickery if the last frame is something close to |
I believe it's common in implementations to provide an argument for the number of stack frames to suppress instead of just blanket ignoring all frames from a given package. As the comment in |
Related: #649 |
Related: #458 |
Summary
When using
sentry.CurrentHub().Recover(err)
to report an exception the stack trace contains that stack frame at the top.Steps To Reproduce
Create recover block:
Have panic after that in a nested function.
Expected Behavior
I expect the top stack frame to be the frame that caused the panic. Instead, it is the stack frame that has the recover. This makes some logical sense, because it is the thing that is calling
sentry.CurrentHub().Recover(err)
but it is unintuitive.Environment
SDK
sentry-go
version: 0.25.0Sentry
The text was updated successfully, but these errors were encountered: