question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

console.error(err) causes standalone app to reload (Android only)

See original GitHub issue

Environment

  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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bengourleycommented, Mar 18, 2019

Could you try to reproduce this in a bare React Native app?

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:

03-18 15:43:34.393  8448  8469 E ReactNativeJS: [Error: floop]

The app does not reload/exit, it just remains interactive.

0reactions
tsapetacommented, Jul 18, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot known issues with Android Emulator
This page lists known issues, workarounds, and troubleshooting tips for the Android Emulator. If you encounter an issue not listed here or ...
Read more >
How can I debug javascript on Android? - Stack Overflow
Log messages from Android appear in the desktop debug console. ... The Galaxy S5 devices shows in Chrome but the tabs only show...
Read more >
How to Fix the "ERR_CONNECTION_RESET" Error (5 Ways)
The “ERR_CONNECTION_RESET” error code is particular to Google Chrome. ... Connection reset errors appear when you visit a website, ...
Read more >
Using Service Workers - Web APIs | MDN
Using a service worker you can set an app up to use cached assets first, ... console.log("Service worker active"); } } catch (error) ......
Read more >
Resolve app installation errors in Google Play Store
Describes workarounds for an error that contains random numbers when you download Office apps from the Google Play ... Google Play Store error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found