react-native
react-native copied to clipboard
[Android] network request fails with exception, but network plugin says it succeeded
I'm making a multipart POST request using any of XMLHttpRequest, Fetch, or Axios. This request succeeds in iOS but fails in Android. The error object i get is "{ isTrusted: false }"
Interestingly, when inspected using the Flipper plugin, the network request actually succeeds with 200 status after ~10s. However, the RN network request failed within 2s.
Description
Copied from Flipper
Full URL https://upload.imagekit.io/api/v1/files/upload
Host upload.imagekit.io
Path /api/v1/files/upload
accept application/json, text/plain, /
Accept-Encoding gzip
Connection Keep-Alive
Content-Length 2308
Content-Type multipart/form-data; boundary=bca65c34-a5a7-4aef-b22d-bf0738b814b5
Host upload.imagekit.io
User-Agent okhttp/3.12.12
--bca65c34-a5a7-4aef-b22d-bf0738b814b5
content-disposition: form-data; name="file"
Content-Length: 1310
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jcW+V/S8g0eT/N3VN3kTqWbQ428m9/8k0P/1aIhF36PccEl6EhOcAUCrXKZXXWS3XKd2vc/TRBG9O5ELC17MmWubD2nKhUKZa26Ba2+D3P+4/MNCFwg59oWVeYhkzgN/JDR8deKBoD7Y+ljEjGZ0sosXVTvbc6RHirr2reNy1OXd6pJsQ+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII=
--bca65c34-a5a7-4aef-b22d-bf0738b814b5
content-disposition: form-data; name="fileName"
Content-Length: 36
d586aff5-9f36-41b5-9097-dcd48d73d32e
--bca65c34-a5a7-4aef-b22d-bf0738b814b5
content-disposition: form-data; name="useUniqueFileName"
Content-Length: 5
false
--bca65c34-a5a7-4aef-b22d-bf0738b814b5
content-disposition: form-data; name="publicKey"
Content-Length: 35
public_VYT09otMm0uvkKMQp9bKbm15lxE=
--bca65c34-a5a7-4aef-b22d-bf0738b814b5
content-disposition: form-data; name="signature"
Content-Length: 40
<redacted>
--bca65c34-a5a7-4aef-b22d-bf0738b814b5
content-disposition: form-data; name="expire"
Content-Length: 10
1624265715
--bca65c34-a5a7-4aef-b22d-bf0738b814b5
content-disposition: form-data; name="token"
Content-Length: 36
<readacted>
--bca65c34-a5a7-4aef-b22d-bf0738b814b5--
access-control-allow-origin *
content-length 381
content-type application/json; charset=utf-8
date Mon, 21 Jun 2021 08:25:17 GMT
etag W/"17d-m8bl/CX9lGKegEGSxtqRbWZD4Nw"
x-ik-requestid 17C276C8F28DA7D60A00016401BB60D04CEB39D24891123cbe3de-0d85-4116-831f-c010656e260f
Response body
{"fileId":"60d04ced37117647e49a2cd4","name":"d586aff5-9f36-41b5-9097-dcd48d73d32e","size":965,"filePath":"/d586aff5-9f36-41b5-9097-dcd48d73d32e","url":"https://ik.imagekit.io/zgbxomd4r/d586aff5-9f36-41b5-9097-dcd48d73d32e","fileType":"image","height":24,"width":24,"thumbnailUrl":"https://ik.imagekit.io/zgbxomd4r/tr:n-media_library_thumbnail/d586aff5-9f36-41b5-9097-dcd48d73d32e"}
React Native version:
System: OS: macOS 11.4 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 1.02 GB / 16.00 GB Shell: 3.2.2 - /usr/local/bin/fish Binaries: Node: 12.21.0 - /usr/local/bin/node Yarn: 1.18.0 - /usr/local/bin/yarn npm: 6.14.11 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 Android SDK: Not Found IDEs: Android Studio: 4.2 AI-202.7660.26.42.7322048 Xcode: 12.5/12E262 - /usr/bin/xcodebuild Languages: Java: 15.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.1 => 0.64.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps To Reproduce
In theory, one can just setup formData with the above information and make a network request in RN to reproduce the issue. However, because the server requires authentication, I have redacted the information needed required to get the same response from the server.
Expected Results
I expect the React Native network code to give me the response found in Flipper Network Plugin
the same issue happend on [email protected] . And I updated Flipper version to 0.110.0, it still send no quest.
the same issue happend on [email protected] (Android 12)
fixed TypeError: Network request failed
when upload file to http not https with Android debug builds
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.