sdk: retry all requests which previous response was a plain 429 without an errcode

This can happen if there's a load-balancer or any modification of the
response by a reverse proxy (e.g. rewrite 5XX errors into 429, to not
let a reverse proxy mark the upstream server as being down, as
Cloudflare seems to do).

As a result, such requests will be retried in multiple places, including
when sending something with the send queue. Also, the send queue will
mark these errors as recoverable instead of unrecoverable.

No test, because the change really is trivial and a regression test
didn't seem worth it, for once.
This commit is contained in:
Benjamin Bouvier
2024-06-25 12:59:59 +02:00
parent 58c687b71b
commit 4d6ee63760

View File

@@ -175,12 +175,15 @@ impl HttpError {
}
_ => Some(e.status_code),
},
RumaApiError::Uiaa(_) => None,
RumaApiError::Other(e) => Some(e.status_code),
RumaApiError::Uiaa(_) => None,
};
if let Some(status_code) = status_code {
if status_code.is_server_error() {
// If the status code is 429, this is requesting a retry in HTTP, without the
// custom `errcode`. Treat that as a retriable request with no
// specified retry_after delay.
if status_code.as_u16() == 429 || status_code.is_server_error() {
return RetryKind::Transient { retry_after: None };
}
}