-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Describe the bug
useSuspenseQuery doesn't throwOnError when used with refetchInterval and the queryFn throws after one successful execution
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/jovial-engelbart-7fxq5c
Steps to reproduce
useSuspenseQuery doesn't throwOnError when used with refetchInterval and the queryFn throws after one successful execution.
Can be seen from the mininmal reproducible example
Expected behavior
useSuspenseQuery throws to ErrorBoundary when queryFn throws an error after the first successful execution.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
All Platform
Tanstack Query adapter
None
TanStack Query version
v5.66.9
TypeScript version
No response
Additional context
also: data is always kept between refetches of the same queryKey. It's just that if you have no data, we go back to a hard loading state. That is per design. data is kept (stale while revalidate refers to showing stale data), errors are not.
throwOnError: query => query.state.data !== undefined
#8591 (comment)
https://github.com/TanStack/query/blob/main/packages/react-query/src/suspense.ts#L11-L19