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
useQuery stuck on loading when ssrForceFetchDelay is set and ssr: false #10474
Comments
Thanks for opening this issue @Ellarddekoeijer 👋🏻 Since I haven't used this config in a production app I'll have to speculate a bit. From the docs:
Here's another relevant snippet: apollo-client/src/react/hooks/useQuery.ts Lines 308 to 315 in 895ddcb
When I drop a breakpoint at line 315, I can no longer reproduce the issue. Interesting! This snippet is also notable: apollo-client/src/core/ApolloClient.ts Lines 170 to 180 in 895ddcb
I was curious whether changing diff --git a/src/index.jsx b/src/index.jsx
index 5310419..c7ee939 100644
--- a/src/index.jsx
+++ b/src/index.jsx
@@ -40,6 +40,8 @@ function App() {
ssr: false
});
+ client.disableNetworkFetches = false;
+
const [addPerson] = useMutation(ADD_PERSON, {
update: (cache, { data: { addPerson: addPersonData } }) => {
const peopleResult = cache.readQuery({ query: ALL_PEOPLE });
Because of this, I wonder whether we need to update the subscription function in our apollo-client/src/react/hooks/useQuery.ts Lines 160 to 167 in 895ddcb
I'm not sure exactly how we might do that given that |
Thanks for your intricate explanation @bignimbus I have applied the disableNetworkFetches workaround to both the reproduction repo and our app (where the problem first occurred), in both cases the query resolved properly and the loading state did not hang. Is there any downside to setting disableNetworkFetches to false at all? I can not seem to find any docs on this topic. Thanks again! |
Thanks for the quick reply @Ellarddekoeijer - if you're noticing that manually unsetting
The only source code in Apollo Client that uses |
Thanks again for your reply @bignimbus, I really appreciate you taking the time! First of I would like to excuse myself for the improper explanation, please let me clarify what I meant with:
About 7 moons ago we had to implement the ssrForceFetchDelay fix because our app had cache restore related issues, therefore it is not possible for us to simply remove it entirely unless this problem is also resolved. I understand this answer is vague, please be patient while I update to the most recent apollo version and research both of these issues. Once I can give a clearer explanation I will post it here! |
We're closing this issue now but feel free to ping the maintainers or open a new issue if you still need support. Thank you! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Issue Description
We ran into the issue where a useQuery does not resolve and gets stuck on loading. After much debugging we figured out that it is due to the combination of useQuery's ssr option being false and ssrForceFetchDelay being set. As a workaround we are using the onCompleted hook to manually set the fetched data.
In our app, where the problem occurred, ssrForceFetchDelay is set to 100. However, to reproduce it I had to set it to 1000 before the issue occurred. Due to circumstances outside of our control we are unable to stray away from using ssrForceFetchDelay. I have seen a few issues about this subject but since these have been closed without the issue seemingly being resolved I am opening another.
Link to Reproduction
https://github.com/Ellarddekoeijer/apollo-ssr-force-fetch-delay
Reproduction Steps
The text was updated successfully, but these errors were encountered: