-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
ReactAndroid: JS errors during bundle load were reported as UnknownCppException #24648
Conversation
Could you rebase this PR on master? |
This fixes a regression on Android introduced by f3e5cce where JS errors thrown during bundle load were lost (shown only as UnknownCppException). It is especially tough to debug (custom) bundling errors without seeing the javascript error. Root cause hypothesis: since switching to clang, JSErrors thrown in ReactCommon's JSCRuntime::checkException were never matched as std::exception in Android's convertCppExceptionToJavaException due to these missing flags.
Ah, apologies, I wasn't aware github actually tracks updates to the origin. I've rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mdvacca is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by Emiel Mols in 6f6696f. When will my fix make it into a release? | Upcoming Releases |
…pException (#24648) Summary: This fixes a regression on Android introduced by f3e5cce where JS errors thrown during bundle load were lost (shown only as UnknownCppException). It is especially tough to debug (custom) bundling errors without seeing the javascript error. Root cause hypothesis: since switching to clang, `JSError`s thrown in ReactCommon's `JSCRuntime::checkException` were never matched as `std::exception` in ReactAndroid's `convertCppExceptionToJavaException` due to these missing flags. I'm a bit shy on low-level details concerning how C++ rtti works exactly around catching exceptions thrown in other libraries. All I can say that with this change, a `bundle.android.js` that only contains `throw new Error("wtf");` now nicely outputs a message and stack trace in the logcat. Before (and since DanielZlotin's switch to clang) it just outputted: ``` 2019-04-29 12:17:59.365 1162-1306/com.rntest E/unknown:ReactNative: Exception in native call com.facebook.jni.UnknownCppException: Unknown at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) at android.os.Looper.loop(Looper.java:214) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232) at java.lang.Thread.run(Thread.java:764) ``` [Android] [Fixed] - JS errors during bundle load were reported as UnknownCppException. Pull Request resolved: #24648 Differential Revision: D15123525 Pulled By: mdvacca fbshipit-source-id: 74b5ce9ebae38d172446b6e31739d795c601947b
Summary
This fixes a regression on Android introduced by f3e5cce where JS errors thrown during bundle load were lost (shown only as UnknownCppException). It is especially tough to debug (custom) bundling errors without seeing the javascript error.
Root cause hypothesis: since switching to clang,
JSError
s thrown in ReactCommon'sJSCRuntime::checkException
were never matched asstd::exception
in ReactAndroid'sconvertCppExceptionToJavaException
due to these missing flags.I'm a bit shy on low-level details concerning how C++ rtti works exactly around catching exceptions thrown in other libraries. All I can say that with this change, a
bundle.android.js
that only containsthrow new Error("wtf");
now nicely outputs a message and stack trace in the logcat. Before (and since @DanielZlotin's switch to clang) it just outputted:Changelog
[Android] [Fixed] - JS errors during bundle load were reported as UnknownCppException.
Test Plan
Might be tricky to test, although an end-to-end on an Android emulator test that checks the logcat for a proper JS stacktrace when the bundle contains invalid JS. No idea if there is infrastructure in place to add this. Any hints?