-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
Describe the bug
useSuspenseQuery seems to have incorrect behavior when select function throws an error. Right now if the select function throws an error, data is set to undefined, which goes against the typed return type.
When queryFn throws an error, it is correctly propagated.
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/qf5gdz
Steps to reproduce
Use the following query and see that query.data is undefined.
const query = useSuspenseQuery({
queryKey: ["key"],
queryFn: () => "my-result",
select: () => {
throw new Error("Something went wrong during select");
},
});Expected behavior
useSuspenseQuery should propagate errors being thrown from select, just like when they are thrown from queryFn.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Irrelevant
Tanstack Query adapter
react-query
TanStack Query version
v5.55.4
TypeScript version
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels