SIGN IN SIGN UP
TanStack / query UNCLAIMED

🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.

0 0 113 TypeScript

fix(react-query): allow retryOnMount when throwOnError is function (#9336) (#9338)

* test(react-query): add tests should retry on mount when throwOnError returns false

* fix(react-query): refine throwOnError retry logic for error boundary cases
When throwOnError is a function, allow retryOnMount to proceed even when error boundary hasn't reset,
while maintaining the prevention behavior for boolean throwOnError values.

* fix(react-query): enhance throwOnError logic in error boundaries

Refine behavior to handle function-type throwOnError, allowing retries when appropriate. Ensure boolean throwOnError values still prevent retries when the error boundary isn't reset.

* test: Add tests for `throwOnError` behavior in `useQuery`

This commit introduces tests to verify the behavior of the `throwOnError` callback in scenarios where `retryOnMount` is enabled. It ensures proper handling of retries based on the error state and the `throwOnError` function's return value. These tests improve the reliability and coverage of error handling logic in `useQuery`.

* fix(react-query): improve throwOnError logic with query state validation

- Pass query object to ensurePreventErrorBoundaryRetry for accurate state checking
- Preserve query deduplication behavior while fixing throwOnError function handling
- Fixes issue where throwOnError function couldn't access query error state

* fix(react-query): fix test flakiness and query cache timing (#9338)

- Replace vi.waitFor with vi.advanceTimersByTimeAsync in tests
- Use separate render results to avoid stale DOM references
- Inline fresh query lookup in ensurePreventErrorBoundaryRetry after _experimental_beforeQuery

* ci: apply automated fixes

* fix(react-query): refine retryOnMount logic and error boundary handling

- move query retrieval after `_experimental_beforeQuery` in `useBaseQuery`
- refactor `ensurePreventErrorBoundaryRetry` for better clarity
- make `query` parameter required in `ensurePreventErrorBoundaryRetry`

* ci: apply automated fixes

* feat(react-query): make query param required but nullable in ensurePreventErrorBoundaryRetry

* Apply suggestions from code review

* chore: size-limit

* chore: changeset

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
S
sangwook committed
4be3ad730c5b8a1e194a91911746be2fce06902a
Parent: 7f47906
Committed by GitHub <noreply@github.com> on 12/30/2025, 2:39:24 PM