[0.66.1] Fetch doesn't return or throw an error
See original GitHub issueDescription
The fetch() method simply doesn’t go through. The await method will wait forever (or just super long).
Version
0.66.1
Output of react-native info
System: OS: macOS 11.6 CPU: (24) x64 Intel® Xeon® CPU E5-2697 v2 @ 2.70GHz Memory: 68.76 MB / 12.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.4.2 - /usr/local/bin/node Yarn: Not Found npm: 8.1.0 - /usr/local/bin/npm Watchman: 2021.06.07.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0 Android SDK: API Levels: 29, 30 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 31.0.0 System Images: android-30 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7678000 Xcode: 13.0/13A233 - /usr/bin/xcodebuild Languages: Java: 11.0.10 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.1 => 0.66.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
Mobx is used in the project and the presenter is fetching a remote json file which is accessible. The fetch() method is defined but somehow, nothing is returned from it so the view is never updated. I tried adding console.log() around it but the line under it is never called. Strangely, it worked in another environment but after reinstalling everything and it doesn’t work again. However, it never worked on this environment.
The remote url is https
so I don’t think it is related to the usesCleartextTraffic. This issue occurs on both Android and iOS.
Snack, code example, screenshot, or link to a repository
const res = await fetch('https://google.com');
const text = await res.text();
Issue Analytics
- State:
- Created 2 years ago
- Comments:13
Top GitHub Comments
@HenryQuan I wasted 1 day trying all solutions to fix this issue, if I set “inlineRequires”: false, in metro config, fetch started working, WTF, now I don’t know if I should keep that false or look for some other solution.
This issue was closed because it has been stalled for 7 days with no activity.