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

Memory leak in vue-query SSR #4953

Closed
schneefux opened this issue Feb 8, 2023 · 2 comments · Fixed by #5015
Closed

Memory leak in vue-query SSR #4953

schneefux opened this issue Feb 8, 2023 · 2 comments · Fixed by #5015
Labels
bug Something isn't working package: vue-query

Comments

@schneefux
Copy link

schneefux commented Feb 8, 2023

Describe the bug

In SSR, Vue will never do app.unmount(), so the query client never unmounts and cannot be garbage collected

Your minimal, reproducible example

https://github.com/schneefux/vue-query-memory-leak-reproduction

Steps to reproduce

npm install
npm run build
npm run start
while true; do curl -s localhost:3000 -o /dev/null; done

Perform a heap dump, for example in Chrome like this:

  • Open Chrome's dev tools
  • Click the NodeJS icon
  • Click the Memory tab
  • Click the trash icon to force garbage collection
  • Click "Take Snapshot"

In the heap dump, open the Summary, set the class filter to QueryClient, observe that there are hundreds/thousands of query clients.

Expected behavior

vue-query should use a different method to unmount during SSR or the SSR docs should explicitly state that you have to call queryClient.unmount() after a request

Platform

Reproduced on macOS and Linux with Nuxt and without a framework (as per https://vuejs.org/guide/scaling-up/ssr.html#rendering-an-app)

TanStack Query version

4.24.4

Additional Context

Related Vue discussions and issues:

@DamianOsipiuk
Copy link
Contributor

@schneefux Could you please check if https://github.com/TanStack/query/releases/tag/v4.24.10 fixes your issue?

@schneefux
Copy link
Author

Thank you, I have been running this in production for a while and have not seen any memory leaks since.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package: vue-query
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants