Skip to content

Conversation

@TkDodo
Copy link
Collaborator

@TkDodo TkDodo commented Feb 21, 2021

pass error as second parameter to retryDelay function

this streamlines the interfaces of retry and retryDelay functions.

One use-case would be to have a retry that depends on the Retry-After header sent from the backend, see also: https://twitter.com/SleeplessByte/status/1362946642513719296

this streamlines the interfaces of retry and retryDelay functions
@vercel
Copy link

vercel bot commented Feb 21, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tannerlinsley/react-query/E4fbcy2cytA3euVCYXTetESubwa2
✅ Preview: https://react-query-git-fork-tkdodo-feature-error-for-retryde-d923d0.vercel.app

Comment on lines -166 to +172
const delay = functionalUpdate(retryDelay, this.failureCount) || 0
const delay =
typeof retryDelay === 'function'
? retryDelay(this.failureCount, error)
: retryDelay
Copy link
Collaborator Author

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

Copy link
Member

@tannerlinsley tannerlinsley left a 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.

@SleeplessByte
Copy link

Oooooh yeah! I only have praise. Thanks @TkDodo!

@TkDodo
Copy link
Collaborator Author

TkDodo commented Feb 23, 2021

Can we merge this?

@tannerlinsley tannerlinsley merged commit fbd3488 into TanStack:master Feb 23, 2021
@tannerlinsley
Copy link
Member

🎉 This PR is included in version 3.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants