From ad253fb02b0999c7248440de2883ef7109f6eaa2 Mon Sep 17 00:00:00 2001 From: Natty Date: Sun, 17 Nov 2024 18:33:12 +0100 Subject: [PATCH] Better AP delivery timeout behavior --- src/model/activity/delivery.rs | 15 ++++++++++----- src/service/federation_client.rs | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/model/activity/delivery.rs b/src/model/activity/delivery.rs index 431a3bd..a85e0b2 100644 --- a/src/model/activity/delivery.rs +++ b/src/model/activity/delivery.rs @@ -47,8 +47,10 @@ pub enum RetriableLocalDeliveryTaskError { #[error("Retriable remote delivery error: {}")] #[serde(tag = "type", content = "detail")] pub enum RetriableRemoteDeliveryError { - #[error("Timeout")] - Timeout, + #[error("Timeout: {0}")] + Timeout(String), + #[error("Timeout: {0}")] + ReqwestTimeout(String), #[error("Response body too large")] BodyLimitExceeded, #[error("Rate limited")] @@ -183,7 +185,10 @@ impl From for DeliveryErrorKind { impl From for DeliveryErrorKind { fn from(value: FederationClientError) -> Self { match value { - FederationClientError::TimeoutError => RetriableRemoteDeliveryError::Timeout.into(), + FederationClientError::TimeoutError => RetriableRemoteDeliveryError::Timeout( + "Reached maximum time for response".to_string(), + ) + .into(), FederationClientError::ReqwestError(e) => e.into(), FederationClientError::JsonError(e) => { RetriableRemoteDeliveryError::Json(e.to_string()).into() @@ -232,11 +237,11 @@ impl From for DeliveryErrorKind { match value { e if e.is_connect() => RetriableRemoteDeliveryError::Connect(format!("{:?}", e)).into(), - e if e.is_timeout() => RetriableRemoteDeliveryError::Timeout.into(), + e if e.is_timeout() => RetriableRemoteDeliveryError::Timeout(format!("{:?}", e)).into(), e if e.is_decode() => { RetriableRemoteDeliveryError::ResponseParse(format!("{:?}", e)).into() } - e if e.is_builder() => InvalidDeliveryTaskError::Reqwest(format!("{:?}", e)).into(), + e if e.s_builder() => InvalidDeliveryTaskError::Reqwest(format!("{:?}", e)).into(), e => RetriableRemoteDeliveryError::GenericReqwest(format!("{:?}", e)).into(), } } diff --git a/src/service/federation_client.rs b/src/service/federation_client.rs index ab8e526..856264c 100644 --- a/src/service/federation_client.rs +++ b/src/service/federation_client.rs @@ -15,7 +15,7 @@ pub(super) fn new_federation_client_service( FederationClient::new( true, 256000, - 20, + 35, UserAgent::from_str(&format!( "magnetar/{} (https://{})", config.branding.version, config.networking.host