-
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
Fetching api response too slow when debugging mode is off #28283
Comments
During my testing checking the server requests, i found out that app add headers that slows the network requests. Requesting when debugging mode on:
Requesting when debugging mode off:
|
Thanks for the issue. It'd really help if you could provide a minimal repro so we can determine if it's something React Native specific or something to do with the configuration of your app. It'd be great if you could provide a snack (or a pointer to a repo with full source). |
Is there any updates about this issue? I am having pretty much a similar one: In my case, fetch calls only works as espected (about 0.5 sec) when react-native-debugger is activated and network inspect is enabled. If not running with this configuration, every fetch call spends about 5 secs. It is also curious that the first fetch call actually works well and, moreover, if I wait 5 secs between calls, they work well too (if I wait 3 secs, then the API request lasts about 2 secs, if I wait 2 second, the API request last about 3 secs). It's like it is no posible completing 2 fetch calls in less than a certain amount of time, more specifically those 5 secs... It is always is the same amount of time. This is so strange, any advice with this problem will be wellcome. |
Same Here First API call takes around 11 seconds. Just a simple API call returns two string in a JSON as a response. |
I just upgraded to react native 0.63.2 and my app became extremely slow on android! I thought maybe there are UI elements that are causing this but now I can see that if i put my app on airplane mode everything works great! so the issue seems to be from Fetches |
We are experiencing the same issues. It's very sporadic - fetch is sometimes very slow or then its sometimes json()/text() functions. Very strange. |
same issues. |
Having a similar issue. Although the fetch API is working fine on the web. On the app, the first fetch takes way too much time. |
Same issue in android real devices for first api with https & working good in emulator |
same issue |
Same issue. |
Same issue. Android only. |
same issue only ios. not always, it sometime |
Posting this to help those who are having this problem. I was using PHP as my backend for the app. Changing to node.js backend helped me. Try Out. I don't know, what is causing this issue. |
Try disabling hermes (set "enableHermes: false" in android/app/build.gradle). I had a similar issue and this fixed it (I'm on react-native 0.60.5). I think the Hermes js engine's handing of fetch requests isn't optimized or something. The reason why this issue would go away when remote debugging is off is because turning on remote debugging switches you to the debugger's (ie Chrome's) JS engine, so you stop using Hermes. If you're experiencing this issue on both iOS and Android, then this probably isn't the correct solution for you. |
Same issue, I've tried both Axios and fetch. On development mode my request takes 0.05s and on prod it takes more than 6s... Anyone has found a solution yet? |
Similar issue. Fetch requests, video and image loading from web takes too long both debug and production. Fetch takes less than 1 second on iOS but on Android it takes about 45-80 seconds. Checked timing - decoding json runs very quickly (~0.6s), web requests are extremely slow. Testing on real device. RN 0.63.3 |
Found a solution for my issue. Maybe it would be helpful for someone. Check IPv6 accessibility for the domain you trying to fetch from. https://ipv6-test.com/validate.php If web server is unreachable check your AAAA records, web server settings or ip6tables settings. |
Same issue, Only ios, But when I use mitmproxy work well. |
same issue on android. |
Same issue on Android |
@victoriaSh The ipv6 solution worked for you? |
Yep! After setting up ipv6 for the domain that I'm using in fetch requests everything works fine. |
@victoriaSh Thanks. The ipv6 solution is working for me also now. |
We're having the same issues using Firebase Cloud Functions (which has a valid IPv6 test). |
Any news on this issue? The first fetch is always taking too slow, no matter what route. When I try to fetch from postman or the browser it is pretty fast. When I try to fetch other apis (such as https://reactnative.dev/movies.json) it is fast, only my project api is slow I restarted my internet connection and it worked for a little bit, but now the problem is back. |
i am have same issue with fetch and axios |
The issue was solved for me after switching to Cloudflare DNS. |
switching to cloudflare DNS didn't work for me. Still getting response after 1m or 2m |
I don't know if this will help, but I restarted sometimes my internet router and the problem was resolved. Not really sure why |
i did following
conclusion - It's not react native specific issue . it's platform specific (Android or ios). |
Yes. The problem seems not to be related to react native. After adding this to method MainApplication#onCreate:
I saw in logs that 2021-09-09 15:48:15.200 2965-3136/? D/OkHttp: [5140 ms] dnsEnd. Do not know what actually causes so long DNS resolving. Related okhttp and retrofit issues which may help: |
Related: A workaround is to prioritise IPv4 over IPv6: #29608 (comment) |
In Android, if you use CTRL + M and go to Settings, you will see in Performance section that "JS Dev Mode" is active. Uncheck this setting and the application start running. |
I'm using react-native 0.69.4 and Expo SDK 46, On Android when I try to make API calls for the first time it'll take longer time to get response after that it works fine. Working fine on iOS devices. Any workarounds let me know. |
Some android devices that don't have ipv6 connection will be delayed initiating network connection when connecting to ipv6 hosts, by updating to okhttp 5.x, overriding okhttp 4.x (which is currently supported use default in react native app - react native version 0.71) will solve this problem. Add below dependencies to
It works ok on android device missing ipv6 View more okttp version at: https://square.github.io/okhttp/changelogs/changelog/ or https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp |
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days. |
This issue was closed because the author hasn't provided the requested feedback after 7 days. |
Description:
Good evening guys,
I am having an issue on my project on both android and iOS:
When i am using the app on debugging mode ON fetching data from api working pretty well, and getting the response just takes 2 seconds;
When i am using the app debugging mode OFF fetching data from api takes more than 11 seconds, i wonder why, and its first time face this issue.
I tried both Axios and Fetch both comes with the same results.
Have anyone faces this issue before?
Bonus: Postman and web-app getting response so fast like on debugging mode is ON
Code Example:
React Native version:
System:
OS: macOS 10.15.3
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 113.79 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.14.1 - /usr/local/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 11.3/11C29 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
Steps To Reproduce
Expected Results
The text was updated successfully, but these errors were encountered: