getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.58k stars 338 forks source link

debug_id is not sent as part of the event #4264

Open saarazari5 opened 6 days ago

saarazari5 commented 6 days ago

What React Native libraries do you use?

Hermes

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

5.35.0

How does your development environment look like?

OS: mac os sonoma Node: 20.18.0 Yarn: 4.3.1 react-native: 10.2.7 hermesEnabled: true newArchEnabled: false

Sentry.init()

using sentry-cli

Steps to Reproduce

  1. follow the guide mentioned in https://docs.sentry.io/platforms/react-native/sourcemaps/uploading/hermes/
  2. generate an error in your react native application.

Expected Result

event should contain debug-id in its payload.

Actual Result

no debug-id is attached to the payload unless you remove usage of deprecated ...eventProcessors.getGlobalEventProcessors() from prepareEvent.js.

also, after removing the usage mentioned, it does add the debug_id payload but bundle image does not have a reference anymore `

krystofwoldrich commented 6 days ago

Hi @saarazari5, thank you for the message,

could you share a bit more details about the issue?


Note that the debugIDs are only generated and added to the events in production bundles.


How do you check the event payload?


bundle image does not have a reference anymore

It that during the source maps upload? Could you share the upload command output?

saarazari5 commented 6 days ago

Hi @saarazari5, thank you for the message,

could you share a bit more details about the issue?

Note that the debugIDs are only generated and added to the events in production bundles.

How do you check the event payload?

bundle image does not have a reference anymore

It that during the source maps upload? Could you share the upload command output?

Hi @krystofwoldrich , thank you for the quick replay, of course:

1) how does sentry separate between a production bundle and dev bundle? since it seems like for some events it did sent debug_id even though the flow was the same.

Image

2) I checked the event payload by pressing "View Json" button on the sentry.io platform Image

3) during the source map uploads its seems like everything is correct, you can see the output in the image Image i also checked that the artifacts were indeed uploaded to sentry by going to the project settings.

the issue seems to be that the trace it self is not associated with the uploaded debug id , i also tried to force the mapping by proxy every access to __sentryDebugIds to return the generated debug_id, it didn't worked.

Image

thank you!

Niryo commented 5 days ago

@krystofwoldrich for more context- in our react native app, we are loading multiple hermes bundles, and now we are trying to fix our bundles sourcemaps. we want to be able to reproduce it from dev, because the production cycles are too long. how can we simulate production for sentry? maybe we can patch something locally to make it work?

krystofwoldrich commented 4 days ago

Thank you @saarazari5 and @Niryo for the details.


how does sentry separate between a production bundle and dev bundle?

The Debug ID is generated for statically generated bundles, that means Debug ID is not generated when bundle is requested over the development server.

When the Debug ID is generated you should see Bundle Debug ID: <debug_id> in the Metro logs.

Together with the Debug ID comment at the end of the plain text bundle and debugId property in the source maps. The bundle should also contain a Debug ID polyfill at the top of the file. Below is unminified version of it.

https://github.com/getsentry/sentry-react-native/blob/ddcabffc8bd015392f28deb4f685ed358889c77e/packages/core/scripts/sentry-debugid-injection-snippet.js#L1-L18

Are _sentryDebugIds and _sentryDebugIdIdentifier globals containing any Debug IDs at runtime?


I checked the event payload by pressing "View Json" button on the sentry.io platform

Perfect, thank you.

saarazari5 commented 4 days ago

Are _sentryDebugIds and _sentryDebugIdIdentifier globals containing any Debug IDs at runtime?

yes indeed, it does print the generated debug_id. when testing in production environment, for some events, the debug_id is sent inside debug_meta however sentry still don't show the unminify code correctly. its show irrelevant code:

Image

you can see that for those different events (which crash at different places in the code) the relevant bundle frames always leads to the same place in the bundle : store.ts.

thanks!

Niryo commented 4 days ago

@krystofwoldrich maybe you can take a look at this event? we do see the debug_id in the raw json, and we do see a source map that contains this id, but for some reason sentry still wasn't able to translate the stack trace of this event

krystofwoldrich commented 3 days ago

Thank you @saarazari5 and @Niryo for the details,

in the example that @saarazari5 shared I see that there are 3 hermes bundles in the stack trace, but only one file is referenced in the event JSON debug images.

That seems to be the issue, we will investigate this further.


Just to confirm, when you symbolicate the stack trace locally, do you use 3 difference source maps one for each bundle?

saarazari5 commented 3 days ago

Thank you @saarazari5 and @Niryo for the details,

in the example that @saarazari5 shared I see that there are 3 hermes bundles in the stack trace, but only one file is referenced in the event JSON debug images.

That seems to be the issue, we will investigate this further.

Just to confirm, when you symbolicate the stack trace locally, do you use 3 difference source maps one for each bundle?

we actually only tried to test it on one bundle, since separating our big bundle to multiple ones is a new feature, we assumed that if we will only reference one of the bundles it will show the original source code of all the frames in the stack that come from this bundle alone, as for the rest of the unreferenced bundles we assumed that if we dont generate debug id and artifacts for them it should not effect the bundle that we want to test.