-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
Network requests silently fail in Android since v0.63.0 #29608
Comments
Fixed Snack link: https://snack.expo.io/2HgnLjyI_ |
With further testing, it seems v0.62.x releases do not work with iOS. Had to downgrade to v0.61.5 to get a release where the network examples work for both platforms. |
Hi @scobo thanks for the issue. I checked out the example and tested it out locally. I did not see the same issue you are experiencing. Could you provide a repo? |
This was 100% repro for us and now it’s zero. I have no idea what was wrong. |
Repro again. AFACIT all I did to trigger it was |
100% repro with the following steps.
|
Same result on iOS now. Flipper indicates the request was successful and I can inspect the response there, but |
|
Finally reproed on 0.61.5. It’s Flipper. Network requests are non-deterministically blocked when Flipper is running. Edit: Nope again. Killed Flipper and still getting no data in render. This is 100% repro in 0.61.5 now, too. |
AFAICT this was due to both VMs being in a bad state, although I don’t know how they got there; the lack of logs and errors made debugging impossible. |
Hey @scobo! Can you provide details on the iOS Simulator or Android Emulator (I assume this is what you meant by "VM") setup that you used to reproduce the issues? Thanks! |
Hi! Your assumption is correct. I created an Android Emulator for a Pixel 3 with API 29. It worked Monday, but after logging in today the fetch example is failing to render again. Flipper indicates the GET was successful:
…but the app itself isn’t rendering the results. Again, it was working on Monday and all I’ve done is reboot. |
Just tried this on an actual Android device (Pixel 4) and I’m getting the same result. And just tried in an iOS Simulator and I get a loading spinner there that never resolves. |
@yungsters I think I tracked this down to the @babel/core & @babel/runtime packages and/or the metro-react-native-babel-preset. I moved the demo apps into our monorepo, where we’re on the latest version of the Babel packages. When I did that, I also upgraded metro-react-native-babel-preset (0.63.0) since we try to keep things up-to-date. I had to downgrade both packages in order to get the networking to work again (7.8.4 for Babel, 0.59.0 for the Metro preset). It appears something changed in either Babel or the Metro preset that causes networking requests to silently fail in React Native (both Android and iOS). You should be able to repro that locally by upgrading those packages after running |
Note: We also had to use
Otherwise Yarn picks up the latest 7.x release since it satifies semver. We still get an infinite loading spinner for iOS, but at least it renders without error. |
Another update: When we build locally for Android, we have network connection and the fetch example renders as intended. When we bundle the same code for release, we get nothing in render. |
No code changes since yesterday, yet today neither the demo app or the one in our monorepo have network connectivity. We’ve tried building from both macOS (two separate machines) and Ubuntu; same result in both environments. Flipper still indicates the requests are successful (and we can access the URL directly from a browser), but there’s nothing in render in the app. |
Ran into a separate issue when trying to repro with an earlier version: #29781 |
Hi, I might have the same issue, did you mean that you can't do any http request or socket connection with any server from your android application ? Have a nice day |
Today’s update: Was able to install an older version of the CLI and successfully run the fetch example from the docs in React Native v0.59.10. However, the same App.js fails to render when using React Native v0.63.2. This is in a separate directory created via |
From macOS, with both a Pixel 2 emulator and a Pixel 4 device:
From Ubuntu 18.04, with both a Pixel 3 emulator and a Pixel 4 device:
Flipper indicates the network request was successful. Closing Flipper and refreshing the app has no affect on the outcome. |
@yungsters Can you try to repro by invoking
We repro’d on a “clean” machine which was able to run the fetch example successfully via |
More info: If we invoke Metro via Also, while this workaround works for the development builds, the release builds still have no network connectivity, e.g., Edit: Running a release build also appears to “poison” the Metro cache. |
Closing this issue since we’ve verified that un-poisoning the Metro cache by running a demo app with the same package name allows us to run debug and release builds of the demo app successfully. It’s still not clear, however, what the issue is when running in our monorepo or how or why running the app in our monorepo poisons the Metro cache for all React Native apps. Since Flipper indicates the network requests are successful, we’re at a loss on how to debug the issue. Any help would be appreciated. |
I'm having a similar problem trying to execute the examples from the network docs. If I enable the network inspect, everything works ok, but on release, the fetch hangs and don't even give me an error. I can reproduce the error following the steps:
Tested using react-native 0.63.4 and 0.62.2 |
Not sure if this is relevant, but I hit an issue a few weeks ago where connections to IPv6 addresses would fail silently in the OkHTTP library on one device I had. Telling OkHTTP to prioritize IPv4 over IPv6 fixed it. |
@danmaas how do you "tell OkHTTP" to prioritize IPv4 from react native? |
@cristianoccazinsp Here is a Gist with the relevant code excerpt: https://gist.github.com/danmaas/c60af5fed9f55d2bc616ce302696540d This overrides the default OkHTTP client factory with a shim that intercepts DNS resolutions and sorts the result list to return IPv4 addresses before IPv6 addresses. |
Description
None of the network examples work in Android since v0.63.0; iOS is unaffected. Confirmed this is still an issue in v0.63.1 and v0.63.2 (the latest as of this report). Failures are silent and simply result in no data being returned to the view.
Since this is an issue with the network APIs, this affects all libraries that rely on those APIs, e.g., Apollo.
React Native version:
Steps To Reproduce
npx react-native init AwesomeProject --version 0.62.2
App.js
with one of the examples from the network docs, e.g., the Fetch Example.npx react-native run-ios
npx react-native run-android
npx react-native init AwesomeProject
App.js
with one of the examples from the network docs, e.g., the Fetch Example.npx react-native run-ios
npx react-native run-android
Expected Results
The results should be rendered as they are on iOS and as they are on versions prior to v0.63.0. At the very least, would expect to see the activity indicator and possibly an error indicating the request failed.
Snack, code example, screenshot, or link to a repository:
https://snack.expo.io/2HgnLjyI_
The text was updated successfully, but these errors were encountered: