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() Network request failed

See original GitHub issue

Environment

OS: macOS High Sierra 10.13.4 Node: 6.11.0 Yarn: 1.7.0 npm: Not Found Watchman: 4.7.0 Xcode: Xcode 9.4 Build version 9F1027a Android Studio: 3.1 AI-173.4697961

Packages: (wanted => installed) react: 16.3.2 => 16.3.2 react-native: ^0.55.4 => 0.55.4

Description

I have a weird issue, which I tried to debug without luck. I launched my app couple days ago in App Store and everything worked fine and even now for most users is working fine. My app is written in React Native and the API Server is using SSL, Xcode setup properly to handle and whitelist the API URL.

2 days ago I received a feedback that 3 GET calls don’t load properly.

My app has 4 tabs on the bottom and doing the following 4 requests on startup:

  1. GET /events?page=1&four_five_extra_query_params
  2. GET /users/me <- without any params
  3. GET /messages?page=1
  4. GET /notifications?page=1

To make these calls, first I am authenticating the user via a POST requests which works fine in every case.

The issue is, for some users when they launch the app the 1st, 3rd and the 4th tab is just loading without any results (the 2nd tab always load properly). Yesterday for 10 minutes my 1st phone had the same issue so quickly tried to debug it. To make it clear, the API server is not down, during these unsuccessful loads from the app, I can make requests to those endpoints from other phones and Postman. Since then my app is working again properly without a single line of change.

This was the error from Google Chrome Debugger:

err TypeError: Network request failed
    at XMLHttpRequest.xhr.onerror (fetch.js:441)
    at XMLHttpRequest.dispatchEvent (event-target.js:172)
    at XMLHttpRequest.setReadyState (XMLHttpRequest.js:567)
    at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:397)
    at XMLHttpRequest.js:503
    at RCTDeviceEventEmitter.emit (EventEmitter.js:179)
    at MessageQueue.__callFunction (MessageQueue.js:351)
    at MessageQueue.js:116
    at MessageQueue.__guardSafe (MessageQueue.js:314)
    at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:115)

Today my 2nd phone started to have this issue, while it’s working perfectly on my 1st phone. So I am still debugging it to come up with a solution. The weird part is if I change the endpoint on the 2nd phone to just /events it loads instantly if I change back to /events?page=1&four_five_extra_query_params then it doesn’t and also doesn’t send the request to the server. If I change the query args or even if just add one to it the app sends the request to the API and loads correctly.

Also a funny thing, I moved my API server to another subdomain, connected to that URL in debugging and everything worked fine, then changed back to the old subdomain and doesn’t work.

The only thing I can think of which doesn’t really make sense that the fetch caches the endpoint and that’s why doesn’t send the request to the server. In those cases when I checking the API server’s log those requests don’t reach the API server.

I know it’s a weird issue, I’ve never seen this before but I hope someone can help and that’d be great. 😃

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
tuanmaicommented, Aug 15, 2018

I got the same weird issue when uprade to react native 0.55

1reaction
ali-ahari-hashemicommented, Jun 27, 2018

Have you found a solution for this? I am having the same error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native fetch() Network Request Failed - Stack Overflow
When I create a brand new project using react-native init (RN version 0.29.1) and put a fetch in the render method to the...
Read more >
HTTP Fetch fails with "TypeError: Network request ... - GitHub
There are 83 issues opened and unanswered about network requests failing with this generic error. The main causes of the pain are: Not...
Read more >
Improve "TypeError: Network request failed" error message
Network request failed, this error occurs usually when api call failed or you have some internet issue. In android emulator, sometimes this error...
Read more >
Fetch Error : [TypeError: Network request failed] : r/reactnative
Fetch Error : [TypeError: Network request failed] ... The error FETCH 1 and FETCH 3 are the same except for FETCH1 I put...
Read more >
Connect to API local error with 'fetch' - Expo SDK - Forums
I did not have a look at your code, but in cases of “Network Request Failed”, I usually run the exact same request...
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