-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
fetch API doesn't resolve or reject #20405
Comments
BTW, I am trying to upgrade my another react-native project from I verify it on my real device moto g5s plus. |
Happens same on my codebase. I upgraded from 0.55 to 0.56 and fetch calls aren't getting completed. However on enabling |
According to the code of event-target-shim, it should work if we use XHR.addEventListener('load', func). But it is not tested on my site. |
In my environment, it works in both of Android and iOS. EnvironmentReact Native Environment Info: |
@ggtmtmgg would you mind to tell me which event-target-shim version you use?? You can simply type The root cause is it doesn't try to call onload when it dispatches load event. It only finds event listeners from events hooked with addEventListener. BTW, I will try to reinstall again to see if this issue still there. |
@john-hu
|
Well. I only have one version of event-target-shim:
and
I will try to make manual change to the react-native folder inside of my node_modules to test if 1.0.5 affects the result. Thank you @ggtmtmgg !! This is a good finding.... I would like to keep my app up-to-date with all dependencies. |
Strange. The same issue cannot be reproduced today. I had re-installed with |
Reopen this issue because it comes to me when I use it with the release build. |
Could this be related to the version of iOS you are running? there were changes to the networking stack to strengthen the network calls. See https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ In at least one external site, even though they were correctly using HTTPS I had to disable Perfect Forward Secrecy otherwise I was seeing similar behaviour. |
@paul-todd2 Thanks for the information. Actually, I use Android smart phone to test it. I found it happens randomly. For some unknown cases, I can reproduce it 100%.... |
@john-hu could you find any solution? |
@msafayasar |
@john-hu I am very obsessed with this problem. I optimized every bit of my server side code because I thought it was because of server but it wasn't. I am very close to publish my app but cannot publish in this condition. I hope someone give proper solution to this |
@msafayasar I never noticed that it is resolved after 60s+ or is never resolved. I just noticed that the speed doesn't make sense. The URL I use is a RSS feed which is hosted at cloudflare. The speed should be fast. My current workaround is to use old version of react native. Old version is so stable. You should also give old version a try if you don't use any new features from 0.56. |
I'm seeing this behavior since upgrading from v0.53.0 to v0.57.0, on both iOS and Android, where calls to I tried pinning |
I tried 0.57.0 today. The debug build can fetch data correctly. But I cannot create release build for my android device. So, it's not clear if I can reproduce this within my app. |
I made a release build of my app. The issue still exists at my app's release build after migrated to 0.57.0. |
@msafayasar Today, I come back to this issue and try to find a workaround. I use the following code which resolves or rejects correctly:
Please give it a try. |
I also had this issue. Apparently |
@alexisbronchart Thanks for this information. I can confirm that this issue is gone after the |
Still having this problem with or without |
I have this issue as well with react-native 0.56.0. |
Would you mind to test if you have #21154 with/without babel class properties? BTW, I think the workaround is still work if you have the issue. Please try it. In my case, I have both of these issues. After removed, everything goes well. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
Is this issue still happening in 0.59? 🤔 |
@kelset I'm having this issue using 0.59.1. It works fine in debug mode, but isn't working when I build the release APK |
I had exact the same problem. The reason was that i had a space hidden in the url. In the debugger worked with that space but without the debugger no |
Can any of you folks kindly provide a repro with the latest 0.59? (Or wait for 0.60? Should come out later this week) |
I found out that my issue was the SSL. My API wasn't using SSL (which isn't allowed in production mode apparently). After I added SSL, I was able to make requests and get responses. I had to add the cert, private key, and chain file before it started working for me. |
@Tino-F |
@NicolasSmit the URL that I was "fetching" was using HTTP instead of HTTPS so instead of
I used
|
@Tino-F |
@NicolasSmit it's done on the server that you're fetching to and it depends on what kind of server you're using whether it's a Node, Apache, Nginx, etc. so the instructions will vary for each. I used let's encrypt to generate the cert, private key & chain file. You can check out their article on how to get started setting up ssl here: https://letsencrypt.org/getting-started/ |
@john-hu The XMLHttpRequest workaround works for me too. Unfortunately, as the babel plugin is part of |
My ios app does not resolve all fetch calls. I updated to RN 0.60.4 and the issue has worsened. @babel/plugin-proposal-class-properties is not part of babelrc file. The fetch call gets stuck and i wait for it to timeout after which it starts working again. Is there any workaround for it? |
@soumyamishra89 Is it in your |
@spsaucier yes its in my package.lock file. Does it affect because of it? |
It affects your project if you can find it at your package.lock or yarn.lock files. |
metro-react-native-babel-preset requires this package. How should i remove it without affecting the packages that requires it? |
Just had this exact issue during react-native upgrade from 0.60.5 to 0.61.2 |
This issue didn't seem to relate to usage of I was previously only clearing the cache via *TMPDIR being /tmp/ or wherever temporary storage is configured for your OS. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
I face the same problem. When the app on production, some users download from App Store and can't fetch any API. This is serious problem. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
This issue had really low interaction in 2020, so I'm going to close and lock this. If you have the issue still, please open a new issue with a good repro with 0.62 so that it can be investigated. |
Environment
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-3540M CPU @ 3.00GHz
Memory: 226.52 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.9.0 - /usr/local/bin/node
Yarn: 1.2.1 - /usr/local/bin/yarn
npm: 5.5.1 - /usr/local/bin/npm
Watchman: 4.7.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
Android SDK:
Build Tools: 23.0.1, 23.0.2, 25.0.0, 25.0.2, 26.0.3, 27.0.3, 28.0.1
API Levels: 14, 15, 16, 17, 18, 19, 20, 22, 23, 25, 26, 8
IDEs:
Android Studio: 3.1 AI-173.4819257
Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
npmPackages:
react: 16.4.1 => 16.4.1
react-native: ^0.56.0 => 0.56.0
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7
Description
Using the example of networking doc to fetch movie.json from facebook server doesn't work.
I had traced the code to dispatchEvent which doesn't trigger load event. The reason is event-target-shim@1.1.1 cannot find any 'load' event listeners.
Reproducible Demo
npm install
react-native run-android
Expected Result
see the following console.log
Actual Result
The text was updated successfully, but these errors were encountered: