bugsnag / bugsnag-js

JavaScript error handling tool for BugSnag. Monitor and report JavaScript bugs & errors.
https://docs.bugsnag.com/platforms/javascript
MIT License
850 stars 251 forks source link

Infinite error loop: Error occurred in onError callback, continuing anyway… #2188

Closed jacywang closed 2 weeks ago

jacywang commented 2 weeks ago

Describe the bug

When the following code block is added to the App.tsx in a react native project,

 try {
    throw new Error('null');
  } catch (err) {
    console.log("--- Bugsnag", Bugsnag.notify);
    Bugsnag.notify(`Something went wrong --- ${err}`);
  }

In react native metro log, Bugsnag reports infinite error loop like the following,

ERROR  [bugsnag] Error occurred in onError callback, continuing anyway…
ERROR  [bugsnag] [TypeError: NativeClient.getPayloadInfoAsync is not a function (it is undefined)]
ERROR  [bugsnag] Error occurred in onError callback, continuing anyway…
ERROR  [bugsnag] [TypeError: NativeClient.getPayloadInfoAsync is not a function (it is undefined)]
ERROR  [bugsnag] Error occurred in onError callback, continuing anyway…
ERROR  [bugsnag] [TypeError: NativeClient.dispatchAsync is not a function (it is undefined)]
ERROR  [bugsnag] Error occurred in onError callback, continuing anyway…
ERROR  [bugsnag] [TypeError: NativeClient.getPayloadInfoAsync is not a function (it is undefined)]
ERROR  [bugsnag] Error occurred in onError callback, continuing anyway…
ERROR  [bugsnag] [TypeError: NativeClient.dispatchAsync is not a function (it is undefined)]
.....

Steps to reproduce

  1. Run npx @react-native-community/cli@ init BugsnagInfiniteLoop --version 0.73.2 to create a new react native project.
  2. Run npx @bugsnag/react-native-cli init to set up Bugsnag. Select Bugsnag version 7.23.0 when asked.
  3. Add the example code snippet mentioned below.
  4. Run yarn Android which will build the app to the Android phone and start the metro.
  5. Right after the app launches on the device, the error loop mentioned above started to show up.

Environment

Example code snippet

In App.tsx,

Bugsnag.start();

function App(): React.JSX.Element {
  const isDarkMode = useColorScheme() === 'dark';

  const backgroundStyle = {
    backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
  };

  try {
    throw new Error('null');
  } catch (err) {
    console.log("--- Bugsnag", Bugsnag.notify);
    Bugsnag.notify(`Something went wrong --- ${err}`);
  }

  return (
    <SafeAreaView style={backgroundStyle}>
......

Error messages

Screenshot 2024-08-23 at 2 37 48 PM

shaylagrymaloski commented 2 weeks ago

I had the same error. Updating @bugsnag/react-native to version 7.25.0 and re installing my pods resolved the error for me.

clr182 commented 2 weeks ago

Hi @jacywang

Please Could you try updating your notifier to the latest version and attempting the suggest as provided by @shaylagrymaloski to see if that solves your issue?

If this issue persists after doing so then please let us know and we can investigate further.

jacywang commented 2 weeks ago

@clr182 @shaylagrymaloski Thanks for your support. Upgrade @bugsnag/react-native to version 7.25.0 indeed fixed the infinite loop issue. However, there is a new warning - Bugsnag.start() was called more than once. Ignoring but it's a separate issue.