sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Sentry syntheticException should not capture it's own stack trace

Open daniel-johns-99 opened this issue 1 year ago • 2 comments

Platform:

  • [X] iOS
  • [X] Android

SDK:

  • [X] @sentry/react-native (>= 5.11.1)

react-native version: 0.68.0

Are you using Expo?

  • [ ] Yes
  • [X] No

Are you using sentry.io or on-premise?

  • [X] sentry.io (SaaS)
  • [ ] on-premise

If you are using sentry.io, please post a link to your issue so we can take a look:

[Link to issue]

Configuration:

(@sentry/react-native)

const sentryConfig = {
      dsn: Config.SENTY_DSN,
      tracesSampleRate: 1,
      integrations: [
        new Sentry.ReactNativeTracing({
          routingInstrumentation,
        }),
      ],
      environment: `${Config.ENVIRONMENT}_${Config.TENANT_CODE}`,
    };
    Sentry.init(sentryConfig);

or


I have the following issue:

When I throw a exception to Sentry using the Sentry.CaptureExpection Method, in the Sentry UI, the internal Sentry JS stack trace is showing and not the error stack trace

Steps to reproduce:

try {
      // Do some logic which might have an error
    } catch (Error) {
      captureException(Error);
    }

Actual result:

The first two lines of the stack trace are internal Sentry stack image Expected result:

[Expected result]

My error should be the top of the stack trace

daniel-johns-99 avatar Apr 04 '24 10:04 daniel-johns-99

Hey @daniel-johns-99 thanks for reporting, we'll investigate. cc @krystofwoldrich

kahest avatar Apr 08 '24 11:04 kahest

Hi @daniel-johns-99, thank you for the message,

from the link and screenshot I see that this the original captured error doesn't have a stack trace, that's why the SDK captures the synthetic exception.

Because non of the frames of the synthetic exception were evaluated as your application frames, the top "Sentry" frame is highlighted.

You can fix this by setting Stack Trace Rules (https://docs.sentry.io/product/data-management-settings/event-grouping/stack-trace-rules/):

This is an example of what you can add based on the screenshot:

stack.abs_path:**node_modules/@yourpackage/react-shared/**                      +app
stack.abs_path:**node_modules/@yourpackage/react-shared/node_modules/**         -app

krystofwoldrich avatar Apr 08 '24 11:04 krystofwoldrich