Skip to content

Uncaught errors are not captured on React Native #655

Closed

Description

@mcrowe

When using Raven in ReactNative, any error that is thrown outside of a try-catch block is not captured. It looks like there was an attempt to capture by calling ErrorUtils.setGlobalHandler. Unfortunately, in production the errors are never captured because the app crashes before the request is complete.

One option is to skip the defaultHandler, which is what causes the app to crash. However, the best behaviour is application-specific.

Perhaps the best solution is to avoid attempting calling ErrorUtils.setGlobalHandler at all in the React Native plugin, and instead to provide documentation for users to do it themselves?

Activity

  1. Kerumen commented on Jul 26, 2016

    @Kerumen

    I have the same problem, in production no errors are logged.

    I don't understand your workaround to get this working.

  2. mcrowe commented on Jul 26, 2016

    @mcrowe
    Author

    @Kerumen . Sorry. My description was a suggestion for how to fix the library, rather than a workaround for users, which is why it was confusing.

    To understand how to change the behaviour yourself, I'd recommend reading through this library's React Native plugin: https://github.com/getsentry/raven-js/blob/master/plugins/react-native.js#L59 . You'll see where it calls ErrorUtils.setGlobalHandler and passes the error along to Raven.captureException. You can override this in your own code, and avoid calling defaultHandler.apply. Then the error will be reported, but the app won't crash.

    To restart the app when there is an error, I used CodePush which already has a utility CodePush.reloadApp. If you aren't using CodePush you'll likely be able to reimplement that functionality, or find a library to do it for you.

  3. Kerumen commented on Jul 26, 2016

    @Kerumen

    Thanks. I still have some troubles with CodePush and Sentry.
    Can you help me? I reached you on Twitter :) Thanks!

  4. benvinegar commented on Jul 27, 2016

    @benvinegar
    Contributor

    This will likely be addressed by #626

  5. HazAT commented on May 10, 2017

    @HazAT
    Member

    Hey,
    Check out our official client for react-native -> https://github.com/getsentry/react-native-sentry
    Closing this here since it's obsolete.
    If you're still having troubles, please create an issue there.
    Thanks

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions