Skip to content
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

Creating an ObservableQuery without subscribing to it creates a lingeringQueryInfo #11445

Open
phryneas opened this issue Dec 21, 2023 · 1 comment

Comments

@phryneas
Copy link
Member

phryneas commented Dec 21, 2023

Issue Description

Reported in #11242 (comment)

Not sure if this is the right place to report this, but we're investigating a memory issue in our next.js server and one of the cause seems to be SSR + useLazyQuery. It looks like even if the options ssr: false is passed to useLazyQuery, the QueryInfo is added to the queries set of QueryManager in the function watchQuery, but since the query is never executed on the server side, it stays in the queries variable forever.

As we use one single instance of ApolloClient, the queries variable of the QueryManager grows until OOM.

@phryneas
Copy link
Member Author

Fixing this will require a lot of work on central core apis, so this will not be able to make in into the memory story of Release 3.9.

So far, our general advice is to create a new ApolloClient instance for every incoming request in SSR.
React doesn't give us any "mounted" or "unmounted" events in SSR, so it's really hard to tear down side effects like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant