Skip to content

useSuspenseQuery doesn't throwOnError when used with refetchInterval #8985

@misoguy

Description

@misoguy

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.

#6290 (comment)

throwOnError: query => query.state.data !== undefined

#8591 (comment)
https://github.com/TanStack/query/blob/main/packages/react-query/src/suspense.ts#L11-L19

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions