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.