react-native: Crash on reportSoftException when lineNumber is missing
š Bug Report
Android app crashes when ExceptionsManagerModule.reportSoftException is called with a stack trace that has frames without lineNumber.
The following fatal exception is logged.
2019-04-09 16:14:29.742 7083-7781/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: co.armortext.messenger, PID: 7083
com.facebook.react.bridge.NoSuchKeyException: lineNumber
at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:124)
at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:128)
at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:182)
at com.facebook.react.util.JSStackTrace.format(JSStackTrace.java:28)
at com.facebook.react.modules.core.ExceptionsManagerModule.reportSoftException(ExceptionsManagerModule.java:46)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
at java.lang.Thread.run(Thread.java:764)
When app is running in debug mode something like this can be shown in red box:
To Reproduce
Log exception via console.error with stack that has frames without line numbers.
Expected Behavior
App should not crash and exception stack trace should be formatted without line numbers similar to how itās shown in red box.
Code Example
I donāt have a good code sample but itās clear that problem is in the following code, where certain fields are assumed to be always present:
Environment
info React Native Environment Info: System: OS: macOS 10.14.4 CPU: (8) x64 IntelĀ® Coreā¢ i7-4850HQ CPU @ 2.30GHz Memory: 1.31 GB / 16.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 11.13.0 - /usr/local/bin/node Yarn: 1.15.2 - /usr/local/bin/yarn npm: 6.7.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 Android SDK: API Levels: 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28 Build Tools: 26.0.1, 26.0.2, 27.0.0, 27.0.3, 28.0.0, 28.0.0, 28.0.2, 28.0.3, 29.0.0 System Images: android-21 | Intel x86 Atom, android-21 | Google APIs Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom IDEs: Android Studio: 3.3 AI-182.5107.16.33.5314842 Xcode: 10.2/10E125 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.59.4 => 0.59.4
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 11
- Comments: 43 (1 by maintainers)
Commits related to this issue
- [bugfix] check line number is present Fixes https://github.com/facebook/react-native/issues/24382 — committed to Salakar/react-native by Salakar 5 years ago
- JSStackTrace -> Ensure lineNumber exists before consuming (#24399) Summary: Fixes https://github.com/facebook/react-native/issues/24382 [ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsi... — committed to wix-playground/react-native by Salakar 5 years ago
- JSStackTrace -> Ensure lineNumber exists before consuming (#24399) Summary: Fixes https://github.com/facebook/react-native/issues/24382 [ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsi... — committed to dsyang/react-native by Salakar 5 years ago
- JSStackTrace -> Ensure lineNumber exists before consuming (#24399) Summary: Fixes https://github.com/facebook/react-native/issues/24382 [ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsi... — committed to facebook/react-native by Salakar 5 years ago
- chore: upgrade to react-native 0.59.4 To fix crashes https://github.com/facebook/react-native/issues/24382 — committed to zhigang1992/devhub by zhigang1992 5 years ago
- JSStackTrace -> Ensure lineNumber exists before consuming (#24399) Summary: Fixes https://github.com/facebook/react-native/issues/24382 [ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsi... — committed to karanjthakkar/react-native by Salakar 5 years ago
- JSStackTrace -> Ensure lineNumber exists before consuming (#24399) Summary: Fixes https://github.com/facebook/react-native/issues/24382 [ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsi... — committed to karanjthakkar/react-native by Salakar 5 years ago
- Downgrade stacktrace-parser from 0.1.6 to 0.1.4 due to https://github.com/facebook/react-native/issues/24382 — committed to standardnotes/mobile by moughxyz 5 years ago
- Fix: App crashes instead of handling error Attempt to fix https://github.com/facebook/react-native/issues/24382 pending https://github.com/facebook/react-native/commit/d7bd6cce38d42dbced48fc8abed9647... — committed to digidem/mapeo-mobile by gmaclennan 5 years ago
- Fix: Fix various crashes and add bugsnag reporting (#148) * Fix: Fix crash on empty or non-numeric Manual GPS coord Move code into try-catch fixes #134 * fix: bugsnag notify instead of console.... — committed to digidem/mapeo-mobile by gmaclennan 5 years ago
- JSStackTrace -> Ensure lineNumber exists before consuming (#24399) Summary: Fixes https://github.com/facebook/react-native/issues/24382 [ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsi... — committed to ubiquity6/react-native by Salakar 5 years ago
- JSStackTrace -> Ensure lineNumber exists before consuming (#24399) Summary: Fixes https://github.com/facebook/react-native/issues/24382 [ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsi... — committed to ubiquity6/react-native by Salakar 5 years ago
- JSStackTrace -> Ensure lineNumber exists before consuming (#24399) Summary: Fixes https://github.com/facebook/react-native/issues/24382 [ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsi... — committed to ubiquity6/react-native by Salakar 5 years ago
Hi everyone,
We have figured it out.
It started due a version bump in one of transitive dependencies of react-native i.e. stacktrace-parser. On 5th April, they released 0.1.5 and this crash started happening.
I can confirm that downgrading it to 0.1.4, by specifying it in package.json, has resolved the issue for us.
Iām using react-native 0.59 and experiencing this issue
Hi @SamMatthewsIsACommonName
The error is thrown here when dev support is not enabled and ExceptionsManagerModule is trying to log a stack trace:
https://github.com/facebook/react-native/blob/9a053fc4db1d926824cf579cbfcabcd664618f9b/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java#L46
I presume reportSoftException is called when in your JS code you do something like console.error(error). This is just a ReactMethod on a ReactModule, so calls to reportSoftException are processed asynchronously by the bridge, exceptions in that method can not be wrapped and re-thrown back inside of sync calls to console.error, JS keeps going while Java is crashing in parallel š And componentDidCatch would be handling some otherwise unhandled JS exceptions in the component tree, but exception that is happening when you try to log original exception via console.error does not result into yet another JS exception.
So, if in componentDidCatch or in any other code your (or some 3rd-party) library calls console.error it will result into call to reportSoftException, unexpected NoSuchKeyException (only in case of certain weird stack traces) that will not be reported back to JS side and will cause app crash (unless you upgrade to more recent react or downgrade the stack parser, of course).
With dev support enabled the call to console.error would result in red box, but JS code would continue execution and would get to componentDidCatch (or in componentDidCatch it would log exception via console.error, thus causing red box, but no crash). With dev support disabled the call to console.error results into unexpected and unhandled (no control is given back to JS side) NoSuchKeyException in reportSoftException, so JS side does not survive past that console.error call in some exception handling code.
Sorry for somewhat lengthy and redundant explanation.
Thank you @yogeshchoudhary147 I find out way to solve this issue. I use yarn install for my project.so I use
"resolutions": { "stacktrace-parser": "0.1.4" }
to build this version .Same crash for us since 5th April. We are on react-native 0.55.4. Donāt know why it started and how to stop it.
This fix was released on 0.59.5 https://github.com/facebook/react-native/releases/tag/v0.59.5
Hi @yogeshchoudhary147 I added in my package.son ādependenciesā: { ā¦, āreactā: ā16.3.1ā, āreact-nativeā: ā0.55.4ā, āstacktrace-parserā: ā0.1.4ā, ā¦ } I built debug android work fine but building release Still error :
Same issue is happening for RN0.59.9 and stacktrace-parser 0.1.6.
Iām having this error on an Android application build , using rn 0.59.3, stacktrace-parser 0.1.6, and node 10.13.0
@helloagain-dev No. This is how my package.json looks like now
"dependencies": { ..., "react": "16.3.1", "react-native": "0.55.4", "stacktrace-parser": "0.1.4", ... },
I am getting the same issue
RN version 0.58 I think it might be a firebase issue Also this is only happening on android Samsung Galaxy S8, S9, S8+, Huwawe P20 lite and pro
For us it also started pretty much the same time the issue was posted. But only with apps that were re-built since then. This looks a little bit like a transitive dependency that has been updated, although we havenāt figured out which one.