Open
Description
Describe the bug
If the query options include the following:
throwOnError: () => false,
retryOnMount: true,
staleTime: Infinity,
then on remount of the host component, queryFn
is not called, even though the documentation suggests otherwise.
Your minimal, reproducible example
https://stackblitz.com/edit/react-93scwtvo
Steps to reproduce
- Wait for the app to load and open the console.
- Click the "Open Modal" button — you will see "Fetching..." messages in the console indicating data fetch attempts.
- Click the "Close Modal" button.
- Click "Open Modal" again — no more "Fetching..." messages appear.
Expected behavior
I expect that if a Query is in the error
status and I set retryOnMount: true
in the options, then when the function passed to throwOnError
returns false
, the Query should still call queryFn
on remount of the host component.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: Windows, macOS;
- Browser: Chrome (137.0.7151.120);
Tanstack Query adapter
react-query
TanStack Query version
v5.81.4
TypeScript version
v5.8.3
Additional context
Here is the link to the source code where the condition is checked that forcibly sets retryOnMount
to false
:
Metadata
Metadata
Assignees
Labels
No labels