-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
bug: useQuery
with a fetch policy of standby
causes SSR to hang
#9108
Comments
I can confirm I am encountering the same bug: I had one place in the code where I was using The same bug occurs on version Apollo Client version 3.5.5. |
We are also experiencing the same issues using the When on Netlify, the SSR fails that uses Downgrading to |
I am also experiencing the same issues using the
|
Same for me. v3.4.17 everything works |
I can confirm the same issue |
I met this issue recently. However, it seems adding This is odd, since useLazyQuery should be skipped in SSR by nature. Could anyone check this? Edit: v3.5.7 just released hours ago, and the situation still the same. Edit2: I just found it('should render', () => {
const link = mockSingleLink({
request: { query: CAR_QUERY },
result: { data: CAR_RESULT_DATA }
});
const client = new ApolloClient({
cache: new InMemoryCache(),
link,
ssrMode: true
});
const Component = () => {
const [, { loading, called, data }] = useLazyQuery(CAR_QUERY); // this will cause render time out
// const [, { loading, called, data }] = useLazyQuery(CAR_QUERY, { ssr: false }); // this will render
expect(called).toEqual(false);
expect(loading).toEqual(false);
expect(data).toEqual(undefined);
return null;
};
const app = (
<ApolloProvider client={client}>
<Component />
</ApolloProvider>
);
return renderToStringWithData(app).then(markup => {
console.log({ markup });
});
}); Edit 3: Checked v3.5.8, v3.6.0-beta.5, and main (43883b3): all of them have the same behavior mentioned above. |
I'm not sure why we did in the first place, but for now we want to pin @apollo/client in the regular dependencies to 3.4.17 because of: apollographql/apollo-client#9108
I'm not sure why we did in the first place, but for now we want to pin @apollo/client in the regular dependencies to 3.4.17 because of: apollographql/apollo-client#9108
I'm not sure why we did in the first place, but for now we want to pin @apollo/client in the regular dependencies to 3.4.17 because of: apollographql/apollo-client#9108
I'm not sure why we did in the first place, but for now we want to pin @apollo/client in the regular dependencies to 3.4.17 because of: apollographql/apollo-client#9108
I'm not sure why we did in the first place, but for now we want to pin @apollo/client in the regular dependencies to 3.4.17 because of: apollographql/apollo-client#9108
I'm not sure why we did in the first place, but for now we want to pin @apollo/client in the regular dependencies to 3.4.17 because of: apollographql/apollo-client#9108
I have a PR that should solve this issue, but there is a possible workaround by setting |
I am using the latest versions and am seeing the same issue with the custom NextJS app that implements isomorphic rendering. Setting @atarek12 can you link me to your PR? |
@byronlanehill you can find the PR here |
@atarek12 @byronlanehill I just tried 3.6.6 (latest) on my repo and it seems to work fine, so whatever problem I had with the prior release 3.5.4 (i hadn't checked for a while) is gone on my end, it could be another issue but still be related to this one I assume. |
The original issue should be fixed in
@atarek12 Can you further explain the issue you're seeing with |
@hwillson The app is freezing and does not compile while using the Here is the failing test for itit('should skip SSR tree rendering if `fetchPolicy` option is `standby`', () => {
const link = mockSingleLink({
request: { query: CAR_QUERY },
result: { data: CAR_RESULT_DATA }
});
const client = new ApolloClient({
cache: new InMemoryCache(),
link,
ssrMode: true
});
let renderCount = 0;
const Component = () => {
const { data, loading } = useQuery(CAR_QUERY, { fetchPolicy:'standby' });
renderCount += 1;
if (!loading && data) {
const { make } = data.cars[0];
return <div>{make}</div>;
}
return null;
};
const app = (
<ApolloProvider client={client}>
<Component />
</ApolloProvider>
);
return renderToStringWithData(app).then(result => {
expect(renderCount).toBe(1);
expect(result).toEqual('');
});
}); |
Thanks @atarek12 @simplecommerce - can one of you share your reproduction that shows this problem with |
@hwillson I created a separate branch demonstrating the bug in my original repo here: https://github.com/simplecommerce/meteor-graphql-app/tree/bug-usequery-fetchpolicy-standby Make sure meteor is installed and execute meteor npm install and meteor run. The page won't load. If you go in this file: |
Not gonna lie, I love reproductions that use Meteor. 🎉 We'll take a look - thanks! |
Updated the title to reflect the fact that |
useQuery
with a fetch policy of standby
causes SSR to hang
Intended outcome:
Render a component that contains a
useLazyQuery
hook.Actual outcome:
The rendering process hangs even if the component is returned.
How to reproduce the issue:
Clone the following repo: https://github.com/simplecommerce/meteor-graphql-app
Make sure meteor is installed and execute
meteor npm install
andmeteor run
.It will run on port 3000.
Load the site, it should render with no issues. It runs on version
3.4.7
of@apollo/client
.Now stop the instance and execute
meteor npm install @apollo/[email protected]
and run the instance again.Now try to load the site, it will hang and eventually time out.
If you go to
https://github.com/simplecommerce/meteor-graphql-app/blob/master/imports/ui/Info.jsx
and place areturn "test";
before theuseLazyQuery
it will render, but if you place it after, it won't.I tried to
console.log
the variables, loading, error, etc, and they all seem ok at first glance, so something else seems to be causing it to time out or hang.I also tried versions 3.5.0 up to 3.5.4 and the same issue occurs.
Versions
The text was updated successfully, but these errors were encountered: