Why the data is not coming and the request is in forever pending mode in the following code sandbox.
https://codesandbox.io/s/charming-margulis-iuwpvf?file=/src/App.js
the code was taken directly from the react query docs - https://tanstack.com/query/latest/docs/react/overview
CodeSandbox
charming-margulis-iuwpvf - CodeSandbox
charming-margulis-iuwpvf using @tanstack/react-query, react, react-dom, react-scripts
Overview | TanStack Query Docs
TanStack Query (FKA React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes fetching, caching, synchronizing and updating server state in your web applications a breeze.
Motivation

7 Replies
passive-yellow•3y ago
That first sandbox link that you pasted seems to work for me. Maybe a temporary issue with the
api.github.com endpoint.
jolly-crimsonOP•3y ago
@julien , there was no issue with the endpoint. I am not able to figure out why it is happening but let me tell you what I have experienced. here you see in the Network,
I switched from
no throttling to fast 3G and it works there when I switched back to no throttling, it stopped working.
I have two wifi connections, one is 5G (my default one) I changed it to 4G and it started working then I switched it back to 5G again and now
I am able to get the data.
this is not the only time , I have got this issue. I have got the same issue 3 times before too.
I am not really sure what could be the root cause of this issue. can you please guess and give me some ideas?
My internet is good because everything works standalone (like axios, fetch) except react-query (with either of them) during that time.
passive-yellow•3y ago
I'm afraid I'm clueless here. To debug this I would try to add a
console.log inside the query function like so:
That'll tell you when the fetching is done. When that happens, isLoading should become false.xenial-black•3y ago
As another point of reference, the sandbox works as expected for me too.
optimistic-gold•3y ago
Are you on macos by any chance? There is a bug in a certain chrome version where navigator.onLine, which we use internally, reports that you are offline even though you are not. Check the
fetchStatus of the query. Is it 'paused'?jolly-crimsonOP•3y ago
Yes, I am using MAC and I use chrome as a browser. When I got this issue the very first time, at that time, I console.log
fetchStatus and it was saying paused.
so this indeed look like a bug in my machine browser. thank you for the RCA.
@TkDodo 🔮 @Louis @julien
this is what MDN is saying about naviagor.onLine
Wondering if there is any plan to develop additional checks apart from navigator.online to find if internet is available.optimistic-gold•3y ago
the only reliable way is to make a fetch request somewhere and see if it succeeds afaik 😅
you can totally add your own event handler to the onlineManager btw if
navigator.onLine isn't good enough