From 4d6ee6376026b43140bbf85eb24822cd07ab2ede Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Tue, 25 Jun 2024 12:59:59 +0200 Subject: [PATCH] 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. --- crates/matrix-sdk/src/error.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/matrix-sdk/src/error.rs b/crates/matrix-sdk/src/error.rs index 50e4603a0..0e1041a50 100644 --- a/crates/matrix-sdk/src/error.rs +++ b/crates/matrix-sdk/src/error.rs @@ -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 }; } }