Production Expo App crashes even with ErrorBoundary
bryanyan opened this issue ยท 5 comments
Describe the bug
I added an ErrorBoundary to my app, but even with an ErrorBoundary my app crashes on errors. In developer mode when I run my app using expo start
, I get an error which I can dismiss and I can see the ErrorBoundary. However, when I run the app in production mode using expo start --no-dev --minify
, the app just crashes. I saw this issue before: #261, but from what I can tell, I'm not triggering the Error in an event handler or any async code. Any ideas? Is this an Expo bug?
Reproduction
App.js
import { useEffect } from 'react';
import { Text, View } from 'react-native';
import ErrorBoundary from 'react-native-error-boundary';
export default function App() {
return (
<ErrorBoundary><ErrorComponent/></ErrorBoundary>
);
}
export function ErrorComponent() {
useEffect(() => {
throw new Error('error in the main app')
}, [])
return <View><Text>This will never render</Text></View>
}
package.json
{
"name": "demo",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"expo": "~46.0.13",
"expo-status-bar": "~1.4.0",
"react": "18.0.0",
"react-native": "0.69.6",
"react-native-error-boundary": "^1.1.16"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
I created this app using npx create-expo-app demo
, and then ran npm install react-native-error-boundary
.
System Info
System:
OS: macOS 12.5.1
CPU: (10) arm64 Apple M1 Pro
Memory: 1.94 GB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.7.0 - ~/.asdf/installs/nodejs/18.7.0/bin/node
Yarn: 1.22.19 - ~/.asdf/installs/nodejs/18.7.0/.npm/bin/yarn
npm: 8.15.0 - ~/.asdf/plugins/nodejs/shims/npm
Watchman: 2022.09.12.00 - /opt/homebrew/bin/watchman
Browsers:
Brave Browser: 105.1.43.88
Safari: 15.6.1
expo-env-info 1.0.5 environment info:
System:
OS: macOS 12.5.1
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.7.0 - ~/.asdf/installs/nodejs/18.7.0/bin/node
Yarn: 1.22.19 - ~/.asdf/installs/nodejs/18.7.0/.npm/bin/yarn
npm: 8.15.0 - ~/.asdf/plugins/nodejs/shims/npm
Watchman: 2022.09.12.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8815526
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
npmPackages:
expo: ~46.0.13 => 46.0.13
react: 18.0.0 => 18.0.0
react-native: 0.69.6 => 0.69.6
npmGlobalPackages:
eas-cli: 1.2.0
expo-cli: 6.0.5
Expo Workflow: managed
Hey!
Can you try running the example provided in the documentation?
https://snack.expo.dev/@carloscuesta/react-native-error-boundary
Thanks
Hey! Thanks for the reply @carloscuesta. I tried it with the example and still get the same thing when running in production mode with expo start --no-dev --minify
. Upon clicking the button, the app just crashes entirely. However, I'm inclined to believe this is actually an Expo/React/React Native issue. After downgrading the expo version to 45 and its other expected dependencies, running the app in production mode doesn't crash the app anymore and just opens up a red error modal.
Will close this out since its not an issue with your package/components. Thanks ๐
Actually, would you happen to remember what version of expo you were on when you wrote the snack? @carloscuesta
. Upon clicking the button, the app just crashes entirely. However, I'm inclined to believe this is actually an Expo/React/React Native issue. After downgrading the expo version to 45 and its other expected dependencies, running the app in production mode doesn't crash the app anymore and just opens up a red error modal.
That's strange, not sure if the behaviour on Expo's side changed about how do they handle errors, but it should not crash the entire application!
Actually, would you happen to remember what version of expo you were on when you wrote the snack? @carloscuesta
Not sure ๐
Let me know your findings, feel free to reach me in case I can be of any help
Thanks ๐
Follow the issue here (in case you run into the same problem): expo/expo#19297