Skip to content

Uncaught errors are not captured on React Native #655

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

Closed
mcrowe opened this issue Jul 15, 2016 · 5 comments
Closed

Uncaught errors are not captured on React Native #655

mcrowe opened this issue Jul 15, 2016 · 5 comments

Comments

@mcrowe
Copy link

mcrowe commented Jul 15, 2016

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?

@Kerumen
Copy link

Kerumen commented Jul 26, 2016

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

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

@mcrowe
Copy link
Author

mcrowe commented Jul 26, 2016

@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.

@Kerumen
Copy link

Kerumen commented Jul 26, 2016

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

@benvinegar
Copy link
Contributor

This will likely be addressed by #626

@HazAT
Copy link
Member

HazAT commented May 10, 2017

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

@HazAT HazAT closed this as completed May 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants