console.error(err) causes standalone app to reload (Android only)
See original GitHub issueEnvironment
Expo CLI 2.7.0 environment info:
System:
OS: macOS Sierra 10.12.6
Shell: 5.2 - /bin/zsh
Binaries:
Node: 10.4.1 - /usr/local/bin/node
Yarn: 1.12.3 - ~/.yarn/bin/yarn
npm: 6.8.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.1 AI-173.4720617
Xcode: 9.2/9C40b - /usr/bin/xcodebuild
npmPackages:
expo: ^32.0.0 => 32.0.2
react: 16.5.0 => 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1
npmGlobalPackages:
expo-cli: 2.7.0
This bug only affects Android Standalone apps.
Steps to Reproduce
Calling console.error()
causes the app to reload in the same way as when there is an unhandled error (e.g. one that is thrown and not caught).
This only happens when the app is running on an Android device (real or virtual) and has been built to standalone. It does not occur when the app is running inside the Expo app.
Expected Behavior
console.error(err)
writes to the device’s log, as per console.log()
, console.info()
, console.warn()
etc. The app remains running in it’s current state.
Actual Behavior
console.error(err)
writes to the device’s log. The app is reloaded and state is lost.
Reproducible Demo
I created a snack, but since they can’t be run in standalone mode it was pointless. Here is the code I was using so that I could trigger the behaviour on-demand (by clicking a button):
<Button title='Press me' onPress={() => {
console.error(new Error('the button was pressed'))
}} />
But you can reproduce this simply by adding console.error()
to an application.
Related/existing issues
I found this forum post which details the same behaviour, but appears to be stale and has no response (regarding the bug, not advice on logging) from the Expo team.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Using the same version of RN (0.57.1) I don’t see this behaviour, using
react-native run-android --variant=release
on the same avd.Logcat output:
The app does not reload/exit, it just remains interactive.
As nothing has happened here for over a year and we haven’t received similar reports, I’m closing it. Let me know if this is still bothering you though.