Skip to content

fetch [TypeError: Network request failed] on iOS 18.4 #50510

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

Open
faustoct1 opened this issue Apr 6, 2025 · 29 comments
Open

fetch [TypeError: Network request failed] on iOS 18.4 #50510

faustoct1 opened this issue Apr 6, 2025 · 29 comments
Labels
Needs: Triage 🔍 🌐Networking Related to a networking API. Platform: iOS iOS applications.

Comments

@faustoct1
Copy link

faustoct1 commented Apr 6, 2025

Description

fetch() was working on 18.2 and older but in the new 18.4 ios is not working it gives the error

[TypeError: Network request failed]

I ran the same code on both simulators and the desirable result didn't work as expected. It happened to me in specific apis like google maps, I tried wikipedia api, it worked! I tested with axios/fetch.

Steps to reproduce

just call google maps fetch(https://maps.googleapis.com/maps/api/place/autocomplete/json?sessiontoken=${sessionToken}&input=${text.replace(/\s+/g,"+")}&key=${this.API_KEY}&limit=10${t}&language=en) it works on ios 18.2 but fails on 18.4. it fails specifically for google maps but works to other endpoints.

React Native Version

0.76.9

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info

info Fetching system and libraries information...
System:
  OS: macOS 15.4
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 483.07 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.4.1
    path: ~/.nvm/versions/node/v22.4.1/bin/node
  Yarn:
    version: 1.22.21
    path: /usr/local/bin/yarn
  npm:
    version: 10.8.1
    path: ~/.nvm/versions/node/v22.4.1/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.14.3
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.4
      - iOS 18.4
      - macOS 15.4
      - tvOS 18.4
      - visionOS 2.4
      - watchOS 11.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.3 AI-243.24978.46.2431.13208083
  Xcode:
    version: 16.3/16E140
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.14
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: ^18.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.9
    wanted: 0.76.9
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

[TypeError: Network request failed]

Reproducer

https://github.com/faustoct1/codes/blob/main/fetch-rn.js

Screenshots and Videos

No response

@react-native-bot react-native-bot added Platform: iOS iOS applications. 🌐Networking Related to a networking API. labels Apr 6, 2025
@faustoct1 faustoct1 reopened this Apr 6, 2025
@devanshsaini11
Copy link
Collaborator

@faustoct1 Can you also try once on latest react-native version: 0.78.x and let us know.
Thanks

@what-is-love54
Copy link

what-is-love54 commented Apr 7, 2025

@devanshsaini11

Same error on ios 18.4:

  • "react-native": "0.78.2",
  • "axios": "^1.8.4",

Image

@trentcowden
Copy link

Also experiencing this issue! I'm getting errors from expo-notifications and expo-file-system related to failed network requests on my iOS simulator and real device using iOS 18.4. I'm using react-native version 0.76.9. Unfortunately, I can't update to 0.78.x as I'm using many Expo libraries!

@johntrinhcode
Copy link

johntrinhcode commented Apr 7, 2025

Running into this too with Expo using the react-native-auth0 library which calls fetch under the hood.

The only way i've found to "get around" this via the iOS simulator is to hit Device -> Erase all content and settings to wipe the state and app binary installation, then reinstall everything.

Restarting the app with Device -> Restart to load a new JS bundle will bring back the [TypeError: Network request failed] fetch error.

@johntrinhcode
Copy link

Looking into it more, requests are stuck in a pending status in the RN devtools.

Image

And mention an issue with Network.streamResourceContent.

Image

@faustoct1
Copy link
Author

@faustoct1 Can you also try once on latest react-native version: 0.78.x and let us know.
Thanks

Hi, I'm running in a deadline I can't upgrade it for now. I'll do it as soon as I get free time. If there's a patch I can try, since it's just run a command meanwhile I'm using rn+expo, it's quite painful to upgrade, and make sure everything is working fine ! I tested on my published app and it's working, it seems to be a problem on simulator.

@faustoct1
Copy link
Author

faustoct1 commented Apr 7, 2025

Running into this too with Expo using the react-native-auth0 library which calls fetch under the hood.

The only way i've found to "get around" this via the iOS simulator is to hit Device -> Erase all content and settings to wipe the state and app binary installation, then reinstall everything.

Restarting the app with Device -> Restart to load a new JS bundle will bring back the [TypeError: Network request failed] fetch error.

I had the same problem with auth. I did exactly this and it worked! I tested on my published app and it's working on a real device, the problem only happened on simulator for me.

I reported this issue here since I faced it first before the fetch issue react-native-google-signin/google-signin#1419

@visoft
Copy link

visoft commented Apr 8, 2025

I can confirm that it works fine on an iOS 18.4 physical device, but there is an error when using the iOS 18.4 simulator.

I erased the 18.4 simulator, rebuilt and installed my app; it worked for about 5 minutes, and then the same problem returned. I went back to the 18.3 simulator, and all is good. Running React Native 0.77.2

@faustoct1
Copy link
Author

I can confirm that it works fine on an iOS 18.4 physical device, but there is an error when using the iOS 18.4 simulator.

I erased the 18.4 simulator, rebuilt and installed my app; it worked for about 5 minutes, and then the same problem returned. I went back to the 18.3 simulator, and all is good. Running React Native 0.77.2

I kept iOS 18.4 due it's not happening on physical device. Those are the related issues I found on 18.4 ios simulator beside the fetch..

RevenueCat/purchases-ios#4954
react-native-google-signin/google-signin#1419

They can somehow be related, all of them seem to happen over the network.

@yvhnpmsky
Copy link

Same for me. Was also able to reproduce it on physical ios devices

Steps to reproduce:

  • Open app
  • Set it to background mode (minimize it)
  • Wait for 3-5 hours
  • Open app again and attempt to make a network request

The request fails with a network error, despite the network being available (confirmed by successfully making a request using axios)

Error code:

Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." 
UserInfo={
  _kCFStreamErrorCodeKey=-4,
  NSUnderlyingError=0x600000cf6a60 {
    Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" 
    UserInfo={
      NSErrorPeerAddressKey=<REDACTED>,
      _kCFStreamErrorCodeKey=-4,
      _kCFStreamErrorDomainKey=4
    }
  },
  _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E4C1DA73-E3D0-4950-A614-4C350ADFFF34>.<10>,
  _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <E4C1DA73-E3D0-4950-A614-4C350ADFFF34>.<10>"
  ),
  NSLocalizedDescription=The network connection was lost.,
  NSErrorFailingURLStringKey=https://<REDACTED>,
  NSErrorFailingURLKey=https://<REDACTED>,
  _kCFStreamErrorDomainKey=4
}

Additional Notes:
• This issue only appears after the app is in the background for an extended period.
• Other requests (e.g. via axios) work fine after resuming.
• Might be related to iOS’s handling of backgrounded apps and stale network sessions.
• Occurs consistently on React Native 0.74.x through 0.76.x (have not tested other versions yet).

@felixspitzer
Copy link

Same problem for us. We have this in revenue cat (react-native-purchases) and firebase (react-native-firebase) also sometimes acts up.

@d-moreira
Copy link

This is an issue that affects iOS 18.4 simulators only. Check this thread for more info.

@revenkroz
Copy link

I had the same problem, but for a website running through Cloudflare - React Native app does requests to it. I temporarily disabled HTTP 3 there and everything worked. Not the best way, but there are too many problems with HTTP 3, as everyone has their own implementation of the protocol. I'll wait for a fix from Apple for 18.4 at least.

Rolling back to old xcode to use old simulators is much longer and will only hinder development if working on multiple projects.

@sagarv1997
Copy link

I have the same issue. When I build the new app by uninstalling and reinstalling it, it works fine. However, after reloading, the network stops working.

@KristianLentino99
Copy link

Same here

@donald-boosted
Copy link

same here using RN 0.76.9 and iOS 18.4.

@Zao721
Copy link

Zao721 commented Apr 17, 2025

Have same issue on 18.3 and 18.4 simulators and one real device (18.3). This issue appears periodically and resolves automatically.

On last week I faced with this issue on real device on application version from App Store

@ghasemikasra39
Copy link

I have this issue on:

IOS simulator version 18.3 
React Native: 0.74.1
Expo: "^51.0.5"

android emulator works fine.

@priemskiyyy
Copy link

Same issue here. I was also able to reproduce it on a real device and emulator. Axios requests work, but fetch does not.
Everything works fine on Android, looks like only ios is affected

react-native: 0.76.9
expo: "^52.0.44

@eybel
Copy link

eybel commented Apr 17, 2025

"expo": "^52.0.46",
"react-native": "0.76.9"

Same here, it happens after a few refreshes. Tried with node 18, node 20.18 and node 20.19.

Safari wont open the page because the network connectin was lost.

This may be an IOS 18.4 simulator issue or Xcode 16.3 issue. Either way you cant install an older IOS simulator if you have Xcode 16 installed... I may wait for a fix or downgrade to Xcode 17.5

@donald-boosted
Copy link

yes I had to downgrade Xcode to 16.2 and use a simulator with iOS 18.3

@astrahov
Copy link

astrahov commented Apr 18, 2025

My observations on the problem:

Simulator: iOS 18.4 (Xcode 16.3, macOS 15.4)

url's:

In the application, a network error occurs when executing the fetch function. There is no problem when opening the same link in Simulator's Safari browser.

@pehagg
Copy link

pehagg commented Apr 18, 2025

Xcode 16.3 and iOS 18.3 sim is a working combo for me. As already pointed out, this is most likely an issue with 18.4 sim.

@eybel
Copy link

eybel commented Apr 18, 2025

Came back to give my feedback and indeed I downgraded to IOS18.3 with Xcode 16.3 and the network error is gone. No need to downgrade Xcode, only the IOS for the simulator.

I use the iPhone 15 Pro with IOS 18.3 and Xcode 16.3 and no error so far.

The problem seems to be the IOS 18.4

@afneyman
Copy link

same issue fixed by downgrading to iOS 18.3 on sim.

@jimji1005
Copy link

No need to downgrade Xcode folks, just download iOS Sim 18.3.1 using Xcode.

@asimak4
Copy link

asimak4 commented Apr 24, 2025

I can attest, this is a IOS 18.4 simulator issue, im also having issues with authentication using firebase and i just keep getting unknown network errors. Downgrading to 18.2 works fine. Need to test on real device but assuming itll be okay.

@AmatoGiulio
Copy link

same

@abbbe
Copy link

abbbe commented Apr 25, 2025

Hitting the same problems - network errors when app runs in Simulator with iOS 18.4.
Occasionally network errors also affect Safari, but that is intermittent.
Downgrade to 18.3 resolves the issue.
Never saw the issue on real device with 18.4, but I only tested few times manually (contrary to Maestro testing in Simulator).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 🌐Networking Related to a networking API. Platform: iOS iOS applications.
Projects
None yet
Development

No branches or pull requests