Unhandled Promise rejection causes UnexpectedNativeTypeException
See original GitHub issueOS:
- Windows
- MacOS
- Linux
Platform:
- iOS
- Android
SDK:
-
@sentry/react-native
-
react-native-sentry
react-native
version: 0.60.5
Init Code:
Sentry.init({
dsn: Config.SENTRY_DSN,
environment: process.env.NODE_ENV || 'development'
});
I have following issue:
When a promise rejection is not handled the sentry sdk crashes with an UnexpectedNativeTypeException. But only if the promise rejects with an object that is not of type Error
. So Promise.reject({bar: 'foo'});
will crash but Promise.reject(new Error('foo'));
and Promise.reject('foo');
will not.
react-native info
info Fetching system and libraries information...
System:
OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
Memory: 105.25 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.9.1 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.10.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: ^16.9.0 => 16.9.0
react-native: ^0.60.5 => 0.60.5
npmGlobalPackages:
react-native-cli: 2.0.1
screenshot:
stacktrace in logcat:
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: Exception in native call
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: com.facebook.react.bridge.UnexpectedNativeTypeException: Value for message cannot be cast from ReadableNativeMap to String
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at com.facebook.react.bridge.ReadableNativeMap.checkInstance(ReadableNativeMap.java:141)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at com.facebook.react.bridge.ReadableNativeMap.getNullableValue(ReadableNativeMap.java:129)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at com.facebook.react.bridge.ReadableNativeMap.getString(ReadableNativeMap.java:163)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at io.sentry.RNSentryModule.sendEvent(RNSentryModule.java:209)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at java.lang.reflect.Method.invoke(Native Method)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at android.os.Handler.handleCallback(Handler.java:873)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at android.os.Handler.dispatchMessage(Handler.java:99)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at android.os.Looper.loop(Looper.java:193)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
09-05 13:56:09.528 7448 7530 E unknown:ReactNative: at java.lang.Thread.run(Thread.java:764)
Steps to reproduce:
Promise.reject({bar: 'foo'});
Actual result:
- App crashes with UnexpectedNativeTypeException
Expected result:
- Report promise rejection
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
What is an unhandled promise rejection? - Stack Overflow
The origin of this error lies in the fact that each and every promise is expected to handle promise rejection i.e. have a...
Read more >Unhandled Promise Rejections in Node.js - The Code Barbarian
One way to cause a promise rejection is to call reject() : ... (node:8383) DeprecationWarning: Unhandled promise rejections are deprecated.
Read more >Tracking Unhandled Promise Rejections - TrackJS
This is a simple example, so catching the rejection is trivial. As promise chains grow larger, it gets more challenging to reason about...
Read more >this error originated either by throwing inside of an async ...
UnhandledPromiseRejectionWarning: Unhandled promise rejection. ... The promise rejected with the reason "AxiosError: Request failed with status code 400".
Read more >Promise Rejection Events Sample
The unhandledrejection event is the promise-equivalent of the global error ... Use a Map to keep track of rejected promises and their corresponding...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed this issue by changing
Sentry.captureMessage('My message', { level: Sentry.Severity.Debug, });
to
Sentry.captureMessage('My message', Sentry.Severity.Debug);
same here with react version 0.61.2 adn sentry 1.0.9