Skip to content

fix(useBaseQuery): set cacheTime to 1 in Suspense mode when cacheTime is set to 0#2821

Merged
TkDodo merged 2 commits into
TanStack:masterfrom
arnaudbzn:fix-cachetime-0-suspense-infinite-loop
Oct 23, 2021
Merged

fix(useBaseQuery): set cacheTime to 1 in Suspense mode when cacheTime is set to 0#2821
TkDodo merged 2 commits into
TanStack:masterfrom
arnaudbzn:fix-cachetime-0-suspense-infinite-loop

Conversation

@arnaudbzn

Copy link
Copy Markdown
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

vercel Bot commented Oct 23, 2021

Copy link
Copy Markdown

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

@TkDodo TkDodo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thank you 🙏

Comment thread src/react/useBaseQuery.ts
Comment thread docs/src/pages/guides/testing.md
@TkDodo TkDodo merged commit 2771a15 into TanStack:master Oct 23, 2021
@tannerlinsley

Copy link
Copy Markdown
Member

🎉 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