Skip to content
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

allow for custom shouldBeRetried handler #46

Closed

Conversation

stefanpl
Copy link

Closes #45

I drafted this so we have something to discuss @sindresorhus. I'll add tests in case the general direction is agreed upon.

Of course, please feel free to edit or suggest changes as you see fit.

@sindresorhus
Copy link
Owner

Should it be shouldBeRetried or shouldRetry?

@sindresorhus
Copy link
Owner

I think we also need to give the user the ability to set the shouldBeRetried option, but also easily get the default behavior if they want.

shouldBeRetried: error => someCondition ? false : defaultBehavior,

Where defaultBehavior is the original !(error instanceof TypeError) || error.isNetworkError check. Not sure the best way to expose this. Could be pRetry.defaultRetryLogic or error.isDefaultRetriable. Or something better?

@acostalima
Copy link
Contributor

acostalima commented May 7, 2021

I like shouldRetry better for the option. What if pRetry exposes a function with the same name as the option, i.e., shouldRetry, to make it concise. The behaviour would be documented anyway.

@sindresorhus
Copy link
Owner

@stefanpl Friendly bump :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom 'should be retried' logic
3 participants