Closed nes123 closed 1 year ago
Hi @nes123, would you mind adding a bit more context around exactly what you are trying to achieve? When you say "print" do you mean having it appear as part of the event information you see on the Bugsnag dashboard? Are you not seeing the stacktrace or event appearing?
https://docs.bugsnag.com/platforms/javascript/reporting-handled-errors/#handled-promise-rejections is recommended way to catch and report rejected promises for react native. Is this what you are currently doing?
Sure thank you for the reply. I have this code block:
AdsConsent.requestInfoUpdate({
// debugGeography: AdsConsentDebugGeography.EEA,
// testDeviceIdentifiers: ["TEST-DEVICE-HASHED-ID"],
})
.then(async (res) => {
if (
res.isConsentFormAvailable &&
res.status === AdsConsentStatus.REQUIRED
) {
AdsConsent.showForm().catch((error) => {
Bugsnag.notify(error);
});
}
})
.catch((error) => {
Bugsnag.notify(error);
});
and getting the following error log in the bugsnag dashboard:
Error Attempted to request a consent info update but the current Activity was null. node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:106:50 promiseMethodWrapper node_modules/react-native-google-mobile-ads/src/AdsConsent.ts:76:11 requestInfoUpdate ~/OpeningPage.js:49:4 anonymous /tmp/hermes/staging/hermes/cmake/intlRelease/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16 tryCallOne /tmp/hermes/staging/hermes/cmake/intlRelease/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27 anonymous (native) apply node_modules/react-native/Libraries/Core/Timers/JSTimers.js:248:12 anonymous node_modules/react-native/Libraries/Core/Timers/JSTimers.js:112:14 _callTimer node_modules/react-native/Libraries/Core/Timers/JSTimers.js:162:14 _callReactNativeMicrotasksPass node_modules/react-native/Libraries/Core/Timers/JSTimers.js:413:41 callReactNativeMicrotasks node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:391:6 callReactNativeMicrotasks node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:133:6 anonymous node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:368:10 guard node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:132:4 flushedQueue node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:128:11 invokeCallbackAndReturnFlushedQueue
the package owner says I should see logs that are coming from the native part to investigate it. As far as I understand the log above shows just the javascript part. I am not sure how to provide more information about this crash.
Hey @nes123
Unfortunately theres not a lot we can do here as we suspect there is no native trace available.
It looks like the API you are using produces the error message via: https://github.com/invertase/react-native-google-mobile-ads/blob/main/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java#L86-L92
Which also appears to swallow the native errors: https://github.com/invertase/react-native-google-mobile-ads/blob/main/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java#L109
You code ends with https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/bridge/Promise.java#L92-L100 which does not include a native Exception at all, and therefore no native stacktrace.
I would suggest going back to the package owner for more clarification.
@johnkiely1 thank you for taking the time to explain it. Very helpful!
In react-native. How to print the native trace when catching a promise error and registering it with Bugsnag.notify?