-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
when using fetch, axios, etc.catch
doesn't handle the error, instead your app crashes
#24249
Comments
what is your React Native version? |
"react-native": "0.59.1". |
I'm having the same issue on both Android and iOS, but with a different library ("react-native-firebase": "^5.2.3"). I don't know if the two things are related, here the issue on the lib tracker invertase/react-native-firebase#1993. "react-native": "0.59.3" |
Is it crashing in debug or release mode? In debug mode a console.error will throw up a red screen, but won't cause a crash in release |
@JKCooper2 yes you right, but until you change your app to release mode, you won't understand it, on the other hand, it bothers a lot when you're in debug mode because you get the red screen and your app restart. If |
oh, I'm sorry you right. I should replace |
👋 closing this issue now as I believe this is resolved, if not please let me know. |
I wish "Hey, BTW, console.error intentionally crashes your app in development." were more prominently documented and/or configurable. |
🐛 Bug Report
To make sure that our request will be successful, first, we check the internet connection then send our request.
This approach was fine until I faced this issue: consider a situation in which access to a server for some countries is blocked.
So, although the internet connection was ok, each time I was getting
network request failed
error and my app was just crashing.Note that this issue is not limited to this problem, it also happens when your internet speed is low, etc.
So, What is the point of catch!? if it doesn't catch the error!?
To Reproduce
react-native init myApp
sending a request to an endpoint which is blocked for your IP.
Expected Behavior
The expected behavior is that, when the connection can't be made, catch gets the error and I can inform the user to use a VPN or leave the app because they are in an embargoed country!
Code Example
Environment
React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Memory: 4.09 GB / 7.90 GB
Binaries:
Yarn: 1.12.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5056338.
The text was updated successfully, but these errors were encountered: