Skip to content

fix: Don't retry for non-recoverable server http errors #212

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

booxter
Copy link
Contributor

@booxter booxter commented Mar 27, 2025

What does this PR do?

This is specifically addressing the issue where server returning Not
Implemented (code 501) would receive two more attempts for the same
request, even though there's no reason to expect it to serve the request
any better on further attempts.

This patch reduces the number of >=500 codes that would be restarted to
those where there seems to be a chance of recover on further attempts.
These codes are now explicitly listed instead of broad >=500 filter.

For all possible server codes, please consult e.g. here:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status#server_error_responses

Test Plan

Client no longer retries requests when server fails.

Injected a fake raise NotImplementedError in one of providers. Then triggered the API. Confirmed that the server no longer logs three times the following, but just once:

"POST /v1/datasets HTTP/1.1" 501 Not Implemented

This is specifically addressing the issue where server returning Not
Implemented (code 501) would receive two more attempts for the same
request, even though there's no reason to expect it to serve the request
any better on further attempts.

This patch reduces the number of >=500 codes that would be restarted to
those where there seems to be a chance of recover on further attempts.
These codes are now explicitly listed instead of broad >=500 filter.

For all possible server codes, please consult e.g. here:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status#server_error_responses

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
@booxter booxter changed the title fix: Don't retry api calls by default fix: Don't retry for non-recoverable server http errors Mar 27, 2025
@booxter booxter marked this pull request as ready for review March 27, 2025 21:48
Copy link

@astefanutti astefanutti left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

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

Successfully merging this pull request may close these issues.

3 participants