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(useBaseQuery): set cacheTime to 1 in Suspense mode when cacheTime is set to 0 #2821

Merged

Conversation

arnaudbzn
Copy link
Contributor

It prevents infinite loop when cacheTime is set to 0 in Suspense mode.
cacheTime is now set to 1 in this case.

Closes #2367

Also added a section in Testing documentation section related to #1847 (Infinity is used instead of 0 to prevent infinite loop for React Query versions without this fix).

This fix is a simple solution to prevent infinite loop when cacheTime is set to 0 but more investigations should be needed about Suspense mode support.
For information, the bug is related to the optionalRemove() call below:
https://github.com/tannerlinsley/react-query/blob/e6da990703482cff8ea99f5a254975cb57463ed5/src/core/query.ts#L432-L435

@vercel
Copy link

vercel bot commented Oct 23, 2021

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/61PJShtXjjJAgXyJQdBqJEG83jzX
✅ Preview: https://react-query-git-fork-arnaudbzn-fix-cachetime-0-7cbf93-tanstack.vercel.app

Copy link
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you 🙏

src/react/useBaseQuery.ts Show resolved Hide resolved
docs/src/pages/guides/testing.md Show resolved Hide resolved
@TkDodo TkDodo merged commit 2771a15 into TanStack:master Oct 23, 2021
@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 3.28.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Infinite loop when to Suspense mode with cacheTime: 0
3 participants