throwOnError: false doesn't work with useSuspenseQueries #9711
Describe the bug#
useSuspenseQueries always throws an error even when throwOnError: false is set for all queries.
I see that the items passed to combine are typed as { data, error }, so I expected combine to be called regardless of errors.
However, combine is never executed when any query fails — even with throwOnError: false.
Your minimal, reproducible example#
Steps to reproduce#
- use
useSuspenseQueries - set
throwOnError: falsefor all queries - throw error in some or all
queryFn
uncomment line 41 in codesandbox
Expected behavior#
I would like useSuspenseQueries to execute without errors, and I would like to have access to the errors in the combine function.
How often does this bug happen?#
None
Screenshots or Videos#
No response
Platform#
Tanstack Query adapter#
None
TanStack Query version#
5.90.2
TypeScript version#
5.6.3
Additional context#
No response
I looked at the source code of
useSuspenseQueriesand tried to useuseQuerieswith{ suspense: true, throwOnError: false }but nothing changed. I'm trying changing throwOnError to callback but it is never executed tooIn my case all but one of the queries aren't necessary. Is there any way to do this without wrapping all the
queryFnin a try/catch?I don't want use
useQuerieswithout suspense for not necessary queries because I'll have to add another loading handler in each componentthrowOnErroris not allowed for suspense because we set this internally. Your reproduction even has a type error because of it:Object literal may only specify known properties, and 'throwOnError' does not exist in type 'UseSuspenseQueryOptions<string, unknown, unknown, readonly unknown[]>'.TkDodo closed this
TkDodo added labelsworks as designed
Sign in to join this conversation.
I think this issue is a fundamental design problem. The throwOnError option in useSuspenseQueries shouldn’t exist at all, as it contradicts the Suspense pattern.
The official Docs also specifies that the
throwOnErroroption does not exist.