Describe the bug
When a queryFn rejects with a falsy value (Promise.reject(), null, '', 0), useQuery throws it to the nearest error boundary, but useQueries and useSuspenseQueries do not.
useSuspenseQueries is the worst case: it renders with data === undefined, even though its types declare data as always defined — so user code dereferences undefined and fails with an unrelated TypeError.
useQueries guards its throw with if (firstSingleResultWhichShouldThrow?.error). The optional chain is needed to narrow Array.prototype.find's T | undefined, but the truthiness check on .error also skips the throw when the error value is falsy. useBaseQuery has no equivalent check.
Your minimal, reproducible example
https://stackblitz.com/edit/github-xu81gzmb?file=src%2Findex.tsx
Steps to reproduce
- Open the StackBlitz link.
- Each of the three hooks rejects with
Promise.reject() (i.e. undefined) inside its own ErrorBoundary.
- Only the
useQuery boundary renders. The useQueries and useSuspenseQueries boundaries do not.
Expected behavior
All three hooks should throw to their error boundary, as useQuery does.
Given identical options and an identical rejection:
| hook |
truthy error |
falsy error |
useQuery + throwOnError |
boundary ✅ |
boundary ✅ |
useQueries + throwOnError |
boundary ✅ |
never throws ❌ |
useSuspenseQueries |
boundary ✅ |
renders data === undefined ❌ |
How often does this bug happen?
Every time
Platform
- OS: macOS
- Browser: any (reproduces in the StackBlitz sandbox)
Tanstack Query adapter
react-query
TanStack Query version
v5.102.5
TypeScript version
v5.8.3
Additional context
Happy to open a PR — I have a one-line fix and regression tests locally.
Describe the bug
When a
queryFnrejects with a falsy value (Promise.reject(),null,'',0),useQuerythrows it to the nearest error boundary, butuseQueriesanduseSuspenseQueriesdo not.useSuspenseQueriesis the worst case: it renders withdata === undefined, even though its types declaredataas always defined — so user code dereferencesundefinedand fails with an unrelatedTypeError.useQueriesguards its throw withif (firstSingleResultWhichShouldThrow?.error). The optional chain is needed to narrowArray.prototype.find'sT | undefined, but the truthiness check on.erroralso skips the throw when the error value is falsy.useBaseQueryhas no equivalent check.Your minimal, reproducible example
https://stackblitz.com/edit/github-xu81gzmb?file=src%2Findex.tsx
Steps to reproduce
Promise.reject()(i.e.undefined) inside its ownErrorBoundary.useQueryboundary renders. TheuseQueriesanduseSuspenseQueriesboundaries do not.Expected behavior
All three hooks should throw to their error boundary, as
useQuerydoes.Given identical options and an identical rejection:
useQuery+throwOnErroruseQueries+throwOnErroruseSuspenseQueriesdata === undefined❌How often does this bug happen?
Every time
Platform
Tanstack Query adapter
react-query
TanStack Query version
v5.102.5
TypeScript version
v5.8.3
Additional context
Happy to open a PR — I have a one-line fix and regression tests locally.