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

fix(mem): Stop leak from cacheTime outliving Query given WeakRef support (v3) #3367

Closed
wants to merge 4 commits into from
Closed

fix(mem): Stop leak from cacheTime outliving Query given WeakRef support (v3) #3367

wants to merge 4 commits into from

Conversation

klarstrup
Copy link
Contributor

@klarstrup klarstrup commented Mar 4, 2022

This change fixes the issue described in SSR: High memory consumption on server in environments with WeakRef support (most importantly Node 14.6+). I believe this will allow entire QueryClient instances to be garbage collected promptly now, even with cacheTimes much longer than the lifetime of the QueryClient instance.

I've included a couple of skipped tests that require being run with --expose-gc to reproduce the problem and confirm the fix, I didn't want to mess with y'all test setup but there they are.

Cheers
Io

@vercel
Copy link

vercel bot commented Mar 4, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tanstack/react-query/CrL3sn3tJRuCGEAeS846duqJKQzx
✅ Preview: https://react-query-git-fork-klarstrup-fix-query-memory-leak-tanstack.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 4, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a7d64e2:

Sandbox Source
tannerlinsley/react-query Configuration
tannerlinsley/react-query: basic-typescript Configuration

@klarstrup klarstrup changed the title fix(mem): Stop leak from cacheTime outliving Query given WeakRef support fix(mem): Stop leak from cacheTime outliving Query given WeakRef support (v3) Mar 4, 2022
@TkDodo
Copy link
Collaborator

TkDodo commented Mar 24, 2022

@TkDodo TkDodo closed this Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants