Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Han5991
Copy link

@Han5991 Han5991 commented Jun 30, 2025

Fixed #9336

Summary

  • Fixed throwOnError retry logic to properly handle function vs boolean values
  • When throwOnError is a function, allow retryOnMount to proceed even when error boundary hasn't been reset
  • Maintains existing prevention behavior for boolean throwOnError values
  • Added comprehensive test coverage for the retry behavior
Han5991 added 2 commits June 30, 2025 23:43
…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.
options.experimental_prefetchInRender
) {
// Prevent retrying failed query if the error boundary has not been reset yet
if (!errorResetBoundary.isReset()) {
options.retryOnMount = false
}
} else if (options.throwOnError) {
if (!errorResetBoundary.isReset() && typeof options.throwOnError !== 'function') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function can return true or false so I think we'd need to evaluate it to get the result

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to evaluate the throwOnError function result instead of just checking if it's a function. Thanks for the feedback!

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.
@Han5991 Han5991 requested a review from TkDodo June 30, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants