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

Implement automatic request retry in the JS client #218

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brianhelba
Copy link
Contributor

No description provided.

// Attach axios-retry to both axios instances
const raxConfig = {
// Retry 3 times on requests that return a response (500, etc) before giving up.
retry: 3,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to provide a limit here. Given the exponential backoff, at a certain point, retries should probably halt.

httpMethodsToRetry: ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT', 'POST', 'PATCH'],
statusCodesToRetry: [[429, 429], [500, 599]],
onRetryAttempt: (err: AxiosError) => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, this library just provides a global handler for the axios instance. I'm not sure if there's an easy way to notify the per-upload progress callback that their upload is currently retrying.

Is it an important feature that the progress callback actually communicate a retrying state, particularly given the fact that retries here will not continue indefinitely?

@brianhelba
Copy link
Contributor Author

This implements automatic request retry using a library, which is a lot less code for us to maintain. In some ways, this has slightly fewer features, but the behavior here is a lot closer to the automatic retry logic that I'd expect to implement for most backends. Retrying a limited number of times automatically, then giving up, is a more conservative behavior for now.

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.

1 participant