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

Multiple tracking.enable$argument_0.onUnhandled error reported #3185

Closed
6 of 11 tasks
elmotan95 opened this issue Jul 13, 2023 · 36 comments · Fixed by #3423
Closed
6 of 11 tasks

Multiple tracking.enable$argument_0.onUnhandled error reported #3185

elmotan95 opened this issue Jul 13, 2023 · 36 comments · Fixed by #3423

Comments

@elmotan95
Copy link

OS:

  • Windows
  • MacOS
  • Linux

Platform:

  • iOS
  • Android

SDK:

  • @sentry/react-native (>= 1.0.0)
  • react-native-sentry (<= 0.43.2)

SDK version: 5.5.0

react-native version: 0.69.10

Are you using Expo?

  • Yes
  • No

Are you using sentry.io or on-premise?

  • 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)

  Sentry.init({
    dsn: 'redacted',
    enableAutoSessionTracking: true,
    environment: config.environment,

    ignoreErrors: [
      // Axios throw error from createError.js, please see useFetch for error log
      /Request\sfailed\swith\sstatus\scode.*/,
      // react-native-fingerprint-scanner
      /.*biometric.*/,
      // appsflyer
      /.*inapps\.appsflyer\.com.*/,
      /.*com\.appsflyer\.sdk\.network.*/,
    ],

    integrations: [
      new Sentry.ReactNativeTracing({
        enableUserInteractionTracing: true,
        routingInstrumentation,
        shouldCreateSpanForRequest: url => {
          const urlRedacted = /redacted/;
          const urlLocalhost = /localhost/;

          return !url.match(urlRedacted) && !url.match(urlLocalhost);
        },
        // ... other options
      }),
    ],

    sampleRate: 0.2,
    // Sessions close after app is 10 seconds in the background.
    sessionTrackingIntervalMillis: 10000,
    tracesSampleRate: 0.2,
  });

I have following issue:

[Description]

I saw issue being logged on Sentry that related to error reporting. Not sure what caused this issues.

tracking.enable$argument_0.onUnhandled


image

Actual result:

[Actual result]

Expected result:

No issues related to sentry reported

@krystofwoldrich
Copy link
Member

Hi,
thank you for the message,
could you share more about the error, are there any breadcrumbs, are there more frames in the stack trace?

@isinuyk
Copy link

isinuyk commented Jul 15, 2023

@krystofwoldrich @elmotan95
Got the same problem on the newly released version of the app.
For me, it is IOS only.

"@sentry/react-native": "^5.4.1",
"react-native": "0.71.7",

@krystofwoldrich
Copy link
Member

@isinuyk Thank you for the information, are you able to reproduce it locally, from the message I assume not, but I want to double-check?

@isinuyk
Copy link

isinuyk commented Jul 17, 2023

@isinuyk Thank you for the information, are you able to reproduce it locally, from the message I assume not, but I want to double-check?

No. I'm not able to reproduce it in debug mode. Only happens on the release version of the app;

@elmotan95
Copy link
Author

Hi, thank you for the message, could you share more about the error, are there any breadcrumbs, are there more frames in the stack trace?

Nope. Data form breadcrumbs does not provide any relevant information (it's only API call with status 200 and screen name). And it does not happened on development apps.

@krystofwoldrich
Copy link
Member

@isinuyk Since you mentioned it's iOS only, could it be incorrect source maps causing the issue, are your other iOS JS errors source mapped correctly?

@isinuyk
Copy link

isinuyk commented Jul 19, 2023

@isinuyk Since you mentioned it's iOS only, could it be incorrect source maps causing the issue, are your other iOS JS errors source mapped correctly?

I don't think so. It is an example of another issue within the same release which has the correct source map

@NiharR27
Copy link

NiharR27 commented Aug 23, 2023

+1 Seeing this on "@sentry/react-native": "^5.7.1" with RN "0.71.12"

This seems to have somehow started after I enabled one of the options here:

Sentry.init({
    dsn: XXXXXXXX,
    environment: XXXXXXXX,
    integrations: [
      new Sentry.ReactNativeTracing({
        tracingOrigins: [XXXXXXXX, /^\//],
        routingInstrumentation,   ===============> NEWLY ADDED THIS
      }),
    ],
    beforeBreadcrumb: (breadcrumb, hint) => {  ===============> NEWLY ADDED this (beforeBreadcrumb function)
      if (['http', 'fetch', 'xhr'].includes(breadcrumb.category))
        return { ...breadcrumb, data: hint };
      return breadcrumb;
    },
    tracesSampleRate: 0.4,
    attachScreenshot: true, ===============> NEWLY ADDED this
  });

on release build.

It is also only happening on iOS devices as mentioned in other comments

cc @abandisch just tagging you here

@krystofwoldrich
Copy link
Member

@NiharR27 Thank you for the information, would you be able to narrow it down? Or share a minimal reproducible example?

@NiharR27
Copy link

NiharR27 commented Aug 29, 2023

@NiharR27 Thank you for the information, would you be able to narrow it down? Or share a minimal reproducible example?

@krystofwoldrich sure, i will try to replicate once I get to the office tomorrow. Additionally, I have also updated the last comment to mention what changes we made recently before pushing (after which the above started)

@NiharR27
Copy link

NiharR27 commented Aug 30, 2023

Still trying to replicate this on release build (when building on my local device).
Here are sentry log however:

Screenshot 2023-08-30 at 10 14 25 am

Screenshot 2023-08-30 at 10 14 45 am

Note: I have hermes enabled. on iOS only.

I have noticed this happening during the app startup (at-least that's what i see in the screenshot that the sentry shows)

Noticed this on iPhone 11 , iPhone 8 Arch:arm64 iOS Version:16.6 (from the error logs that we been getting). and it is handled (not crashing the app).

I will post something in this post, in-case i find more / able to replicate

@isinuyk
Copy link

isinuyk commented Aug 31, 2023

The interesting thing is that right after I made a codepush to the affected by this problem latest IOS release the title and traces for this issue changed a bit. Now it looks like:

@krystofwoldrich
Copy link
Member

krystofwoldrich commented Aug 31, 2023

@isinuyk This stack trace looks correct since there was no stack trace with the original error Sentry captures synthetical error at the time to show the current stack trace.

@Bardiamist
Copy link

Same problem, 4 users, 5 events

Error: [{}]
  at tracking.enable$argument_0.onUnhandled(node_modules/@sentry/react-native/dist/js/integrations/reactnativeerrorhandlers.js:85:57)
  at onUnhandled(node_modules/promise/setimmediate/rejection-tracking.js:73:25)
  at apply(native)
  at setTimeout(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:213:35)
  at _callTimer(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:113:15)
  at callTimers(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:359:30)
  at apply(native)
  at __callFunction(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:428:32)
  at __guard$argument_0(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:113:43)
  at __guard(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:367:7)
  at callFunctionReturnFlushedQueue(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:18)

@ts-ign0re
Copy link

Same problem guys
image

@krystofwoldrich
Copy link
Member

krystofwoldrich commented Sep 11, 2023

@ts-ign0re Thanks for the info, were you able to reproduce it locally? Does it happen on both iOS and Android? Are other errors symbolicated correctly?

@MarkHaakman
Copy link

For me it also happens on Android.
8 users with 291 events. RN 0.71.13, Sentry 5.9.1.
I could not reproduce it locally.

@krystofwoldrich
Copy link
Member

@Kowaio Thank you for the information, we will keep you posted on any updates regarding this issue.

@lucasftcruz
Copy link

Facing the same issue on iOS. For us started coincidentally when we updated RN 0.70.9 to 0.70.13. I'm not able to reproduce the issue and can confirm it only happens on release builds

"react-native": "^0.71.14",
"@sentry/react-native": "^5.4.0",

Screenshot 2023-11-08 at 2 17 36 PM

@krystofwoldrich
Copy link
Member

@lucasftcruz The stack trace you shared looks correct, you can ignore the first frame pointing to Sentry, that's present because we report the unhandled Promise rejection.

@savv
Copy link

savv commented Nov 17, 2023

We are also seeing this error on iOS right after Codepush installs a bundle and it causes the app to crash. We can replicate this ~50% of the time on one of our devices by a) freshly installing the app b) selecting "Install" on the Codepush prompt*. Skipping b) means that the app does not crash. I am not sure if this is caused by Sentry, but I thought I would report my findings.

The stack trace, which similar to the above seems to start here:

  1. in callFunctionReturnFlushedQueue
  2. Then this invariant seems to trigger in line 428: Failed to call into JavaScript module method ${module}.${method}(). Module exists, but the method is undefined.
    This would further suggest that it's related to Codepush. For example, Codepush invalidates all RCTBridges when it restarts (which happens when a new bundle is installed.)

The one thing that doesn't fit the above, is that I don't see this error message anywhere. Maybe invariant is not creating the error in a way that is compatible with sentry. Maybe "Error: 1" comes from here?

image

* Our codepush config checks for updates when the app starts, and asks the user whether they want to upgrade; if you press "Install", we install the new bundle immediately. Config: {checkFrequency: codePush.CheckFrequency.ON_APP_RESUME, installMode: codePush.InstallMode.IMMEDIATE,updateDialog: {}}

@krystofwoldrich
Copy link
Member

@savv Thank you for the detailed findings.

@savv
Copy link

savv commented Nov 17, 2023

@savv Thank you for the detailed findings.

reactnativeerrorhandlers.ts seems to polyfill Promises, in order to catch unhandled promise rejections, but I wasn't able to trigger that code.

When does onUnhandled ever execute? How can I get it to?

@krystofwoldrich
Copy link
Member

The onUnhandled get triggered on unhandled promise rejection.

The SDK reports that there was unhandled rejected promise, but the top of the stack should exclude the Sentry frame.

@savv
Copy link

savv commented Nov 17, 2023

The onUnhandled get triggered on unhandled promise rejection.

The SDK reports that there was unhandled rejected promise, but the top of the stack should exclude the Sentry frame.

I see, so as invariant sets error.framesToPop = 1; maybe there's a bug in addGlobalEventProcessor / parseErrorStack or it's incompatible with Sentry's promise handling. Although I wasn't able to replicate it.

@krystofwoldrich
Copy link
Member

@savv Thank you, we'll investigate it.

@savv
Copy link

savv commented Nov 17, 2023

As a final FYI, I also just saw that RN 0.72.7 includes the following fix:

Show correct stack frame on unhandled promise rejections on development mode.
facebook/react-native@18c9797

While I didn't look at the code it could be related. Thanks again

@birgernass
Copy link

@savv were you able to get to the bottom of the Error: 1 issue? We see these events very frequently since upgrading to 5.15.x from a 5 alpha version.

@rodolfoBee rodolfoBee reopened this Jul 10, 2024
@rodolfoBee
Copy link
Member

Reopening issue as users are getting these reports in the newest versions of the SDK. The issue does not seem to be caused by the SDK, it is simply being reported by it.

@krystofwoldrich can you please confirm it from the Mobile SDK team side?

@ts-ign0re
Copy link

ts-ign0re commented Jul 10, 2024

If you encounter this problem, try to find the following line in your code or in the code of the libraries you use

return Promise.reject();

my case was due to the similar use of Promise, which caused onUnhandled

This is not a Sentry bug, however Sentry does not handle Promise correctly and does not indicate in which line the unhandled promise occurred

@krystofwoldrich
Copy link
Member

@rodolfoBee I can confirm, this is not an issue caused by the SDK. The SDK just captures a Promise rejection without any additional information, without a stack trace attached.

This can happen for example when Promise.reject() is called without an error instance. Like @ts-ign0re mentioned.

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

Successfully merging a pull request may close this issue.