Describe the bug#
When throwing an error from a useSuspenseQuery like described here resetting the QueryErrorResetBoundary does not reset the error in useSuspenseQuery.
This happens when the error occurs on a subsequent fetch. It works as expected, if the error occurs while fetching data initially.
Your minimal, reproducible example#
https://stackblitz.com/edit/github-vmd3m2?file=src%2Fcomponents%2FProjects.jsx
Steps to reproduce#
- Click on "Show Projects"
- Click on "Refresh"
- Click on "Try again"
- The
ErrorBoundary fallback is still shown
Expected behavior#
After 3. the Suspense fallback should be shown and after a short while the project list should be shown.
How often does this bug happen?#
Everytime
Screenshots or Videos#
https://github.com/TanStack/query/assets/28823153/4712012b-a42a-4735-959c-27067d517b13
No response
Platform#
- OS: MacOS 14.4.1
- Browser: Chrome 124.0.6367.209
Tanstack Query adapter#
react-query
TanStack Query version#
5.37.1
TypeScript version#
No response
Additional context#
No response
I think there is one render cycle in between where we are still in
errorstate. I need to look into this. A quick workaround would be: