-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Feature/error for retry delay #1838
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
Feature/error for retry delay #1838
Conversation
this streamlines the interfaces of retry and retryDelay functions
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/tannerlinsley/react-query/E4fbcy2cytA3euVCYXTetESubwa2 |
| const delay = functionalUpdate(retryDelay, this.failureCount) || 0 | ||
| const delay = | ||
| typeof retryDelay === 'function' | ||
| ? retryDelay(this.failureCount, error) | ||
| : retryDelay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why || 0 was needed here before. On type level, the function was only allowed to return a number, and we also use the defaultRetryDelay in case retryDelay was undefined
tannerlinsley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Derk will be happy about this one.
|
Oooooh yeah! I only have praise. Thanks @TkDodo! |
|
Can we merge this? |
|
🎉 This PR is included in version 3.12.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
pass error as second parameter to retryDelay function
this streamlines the interfaces of
retryandretryDelayfunctions.One use-case would be to have a retry that depends on the
Retry-Afterheader sent from the backend, see also: https://twitter.com/SleeplessByte/status/1362946642513719296