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.

Fetch failures on Android

See original GitHub issue

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

Fetch POST and PUT requests, to https endpoints, fail with “Network request failed”, on android simulator. We’re observing this after upgrading from 0.59.10 to 0.61.5. We can’t upgrade further (yet) given other dependencies breaking.

Observation: Adding a Header object to these requests, as opposed to empty, or JS’ empty object {}, leads to different behavior. All these requests work as-is on iOS. See simplified code samples.

React Native version: 0.61.5

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

// works on 0.59.10. doesn't work on 0.61.5
fetch('target-url', {
    method: 'POST'
    headers: { h1: 'val1' } // fails where it used to succeed. Network Request Failed.
})

let h =  new Headers()
h.set('h1', 'val1')
fetch('target-url', {
    method: 'POST'
    headers: h // strangely succeeds.
})

Expected Results

Expect prior requests from 0.59.10, as described above, to work across iOS and Android.

Snack, code example, screenshot, or link to a repository:

See above.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ambarccommented, Aug 29, 2020

It’s very similar, but I think that issue might be running into broader problems. I’m trying to keep this issue open and focused on the presence of Headers being the difference between pass / fail on Android.

1reaction
therealanshcommented, Aug 28, 2020

Are you using a localhost api? If so try changing the target url to http://10.0.2.2 for android emulator and if you are trying it on a real device try changing the endpoints to your computer’s local IP address. But it is strange that it used to work before v0.61.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

Network request failed on Android device using fetch
I've got error "Network request failed" when using fetch in React Native on Android emulator/real device. The code is below:
Read more >
IssueTracker - Google
I just downloaded the SDK (the .zip) and I'm getting this error. I'm on Windows 7. The error shown in the Android SDK...
Read more >
Android build sometimes fails to fetch Gradle 6.9.2
Android builds sometimes fail because Gradle 6.9.2 can't be fetched from gradle.org. Environment. Where did the issue happen? On bitrise.io with ...
Read more >
Issue when doing an initial fetch android-4.2.2_r1.2
to android-...@googlegroups.com. When running 'repo sync', I get the following errors. I'm at 98% with 325 out of 329. My .repo directory is...
Read more >
fetch() - Web APIs | MDN
The global fetch() method starts the process of fetching a resource from the network, ... A fetch() promise does not reject on HTTP...
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