You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uncaught errors are not captured on React Native #655
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 . 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.
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
Reacted by Mark Allen, Martin Møller and iron-cherep
Activity
Kerumen commentedon 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 commentedon 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.setGlobalHandlerand passes the error along toRaven.captureException. You can override this in your own code, and avoid callingdefaultHandler.apply. Then the error will be reported, but the app won't crash.To restart the app when there is an error, I used
CodePushwhich already has a utilityCodePush.reloadApp. If you aren't usingCodePushyou'll likely be able to reimplement that functionality, or find a library to do it for you.Kerumen commentedon Jul 26, 2016
Thanks. I still have some troubles with CodePush and Sentry.
Can you help me? I reached you on Twitter :) Thanks!
benvinegar commentedon Jul 27, 2016
This will likely be addressed by #626
HazAT commentedon 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