sentry-react-native
sentry-react-native copied to clipboard
Unhandled promise rejections will not be caught by Sentry warning not working (only logging message)
Environment
How do you use Sentry? Sentry SaaS (sentry.io)
Which SDK and version? @sentry/[email protected]
Steps to Reproduce
Run the app.
Expected Result
There should be one of these logs from https://github.com/getsentry/sentry-react-native/blob/f916f2b3afbb9884f9037b8486539ca6cc8b327c/src/js/integrations/reactnativeerrorhandlers.ts#L141:
Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.Unhandled promise rejections will be caught by Sentry.Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.
Actual Result
No message in logs.
Replacing:
logger.warn("Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.");
by
setTimeout(() => console.warn("Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page."), 0);
solves the issue (setTimeout and console instead of logger are both required). Maybe the logger is not yet ready at this time...
@jer-sen where do you init the Sentry SDK? I can't reproduce that, I always get the logs. Can you provide a minimal reproduction example? thanks.
@marandaneto in a file imported from my index.js. I think it's not a bug of Sentry but when a console.log is called before AppRegistry.registerComponent (or registerRootComponent for Expo) has been executed (e.g. at the top level of a file imported directly or indirectly from index.js), the logs are lost. So, for our warnings about Sentry and promises we have 2 options:
- ask people in the doc to initialize Sentry not too early, basically in
index.jsafter registering the component or during the root component first render => but Sentry may miss some early errors - add a
setTimeout(registering the component is required synchronously, so we are sure that theconsole.logwill be triggered after registering the component)
@jer-sen so it's not about the unhandled promise not working at all, but rather the logging that tells you if it's working or not, does it make sense?
Yes, exactly.
Le ven. 24 juin 2022 à 13:57, Manoel Aranda Neto @.***> a écrit :
@jer-sen https://github.com/jer-sen so it's not about the unhandled promise not working at all, but rather the logging that tells you if it's working or not, does it make sense?
— Reply to this email directly, view it on GitHub https://github.com/getsentry/sentry-react-native/issues/2268#issuecomment-1165501712, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQFELO46KATQTSC76Q2HXTVQWPBHANCNFSM5YGCGJ6Q . You are receiving this because you were mentioned.Message ID: @.***>
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Still an issue!
In our sample app we also init Sentry before AppRegistry.registerComponent(appName, () => App); but the JS logs are printed out as expected.
Example from a run on iOS, Sentry SDK version 4.7.1.
2022-10-27 15:00:17.510197+0200 sample[18388:6697968] [javascript] 'Sentry Logger [log]:', 'Unhandled promise rejections will be caught by Sentry.'
So is this still an issue @jer-sen ?
I will update and try but not now. Probably in 2 weeks.
any updates here @jer-sen ?
any updates here @jer-sen ?
Not yet, but still in my mind
Hi @jer-sen, any update?
Not yet, and not in the coming days. Maybe you should close the issue and I will update you when I will have time to check.
@krystofwoldrich I have (finally!) updated to @sentry/[email protected] (latest version supported by sentry-expo) and the issue is still here. When I patch (with patch-package) @sentry/react-native like this
diff --git a/node_modules/@sentry/react-native/dist/js/integrations/reactnativeerrorhandlers.js b/node_modules/@sentry/react-native/dist/js/integrations/reactnativeerrorhandlers.js
index ab21a2a..09388e5 100644
--- a/node_modules/@sentry/react-native/dist/js/integrations/reactnativeerrorhandlers.js
+++ b/node_modules/@sentry/react-native/dist/js/integrations/reactnativeerrorhandlers.js
@@ -93,14 +93,20 @@ export class ReactNativeErrorHandlers {
const Promise = require('promise/setimmediate/es6-extensions');
if (Promise !== RN_GLOBAL_OBJ.Promise) {
logger.warn('Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.');
+ // For message to appear
+ setTimeout(() => console.warn('Console.warn: Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.'), 0);
}
else {
logger.log('Unhandled promise rejections will be caught by Sentry.');
+ // For message to appear
+ setTimeout(() => console.log('Console.log: Unhandled promise rejections will be caught by Sentry.'), 0);
}
}
catch (e) {
// Do Nothing
logger.warn('Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.');
+ // For message to appear
+ setTimeout(() => console.warn('Console.warn: Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.'), 0);
}
}
/**
I can only see Console.log: Unhandled promise rejections will be caught by Sentry. in event breadcrumbs.
@jer-sen This is likely caused by the order in which the integrations are initialized. The Breadcrumbs integration is initialized after the ReactNativeErrorHandlers .
@krystofwoldrich ok but then in my opinion the warning is useless if we can't get it in the breadcrumbs
@jer-sen It's meant for local debugging once it's set up it should not change in production.
Ok. With dev client build (using Expo) I can see the logs.