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.

[0.66.1] Fetch doesn't return or throw an error

See original GitHub issue

Description

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:closed
  • Created 2 years ago
  • Comments:13

github_iconTop GitHub Comments

6reactions
Harshpinder-singhcommented, Nov 2, 2021

@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.

0reactions
github-actions[bot]commented, Jul 2, 2022

This issue was closed because it has been stalled for 7 days with no activity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native fetch() Network Request Failed - Stack Overflow
1) and put a fetch in the render method to the public facebook demo movie API, it throws a Network Request Failed ....
Read more >
fetch() - Web APIs | MDN
The global fetch() method starts the process of fetching a resource from the network, returning a promise which is fulfilled once the response...
Read more >
Troubleshooting - React Native
If you encounter an error such as npm WARN locking Error: EACCES while using the React Native CLI, try running the following:.
Read more >
When That's Not So Fetch: Error Handling With fetch()
According to the fetch() MDN, the Promise object returned by the fetch() call is rejected (throws an error) only when "a network error...
Read more >
Handling Failed HTTP Responses With fetch() - TJ VanToll
Per MDN, the fetch() API only rejects a promise when a “network error is encountered, although this usually means permissions issues or similar....
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