mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-19 06:04:31 -04:00
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:
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user