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

Add HTTP retry mechanism #256

Merged
merged 5 commits into from
Jul 16, 2021
Merged

Add HTTP retry mechanism #256

merged 5 commits into from
Jul 16, 2021

Conversation

fweikert
Copy link
Member

Bazelisk now retries failing HTTP requests whose status code indicates that a retry makes sense (e.g. 429, 503).
It considers a variety of HTTP headers (such as Retry-After, X-RateLimit-Reset, Rate-Limit-Reset) in order to determine when to retry.
If no such header is present Bazelisk employs an exponential backoff retry strategy (with some randomness).

Fixes #254

Bazelisk now retries failing HTTP requests whose status code indicates that a retry makes sense (e.g. 429, 503).
It considers a variety of HTTP headers (such as Retry-After, X-RateLimit-Reset, Rate-Limit-Reset) in order to determine when to retry.
If no such header is present Bazelisk employs an exponential backoff retry strategy (with some randomness).

Fixes bazelbuild#254
@fweikert fweikert requested a review from philwo July 16, 2021 11:11
// ReadRemoteFile returns the contents of the given file, using the supplied Authorization token, if set. It also returns the HTTP headers.
// If the request fails with a transient error it will retry the request for at most MaxRetries times.
// It obeys HTTP headers such as "Retry-After" when calculating the start time of the next attempt. If no such header is present, it uses an exponential backoff strategy.
Copy link
Member

Choose a reason for hiding this comment

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

nit: line-break after "... of the next attempt."?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@philwo philwo left a comment

Choose a reason for hiding this comment

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

Wow, nice!

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.

Add HTTP request retries where they make sense
2 participants