diff --git a/crates/routes/src/images.rs b/crates/routes/src/images.rs index 5dcb1b9dd..edd8fc8d4 100644 --- a/crates/routes/src/images.rs +++ b/crates/routes/src/images.rs @@ -11,7 +11,7 @@ use actix_web::{ HttpResponse, }; use futures::stream::{Stream, StreamExt}; -use lemmy_utils::{claims::Claims, rate_limit::RateLimit}; +use lemmy_utils::{claims::Claims, rate_limit::RateLimit, REQWEST_TIMEOUT}; use lemmy_websocket::LemmyContext; use reqwest::Body; use reqwest_middleware::{ClientWithMiddleware, RequestBuilder}; @@ -65,7 +65,9 @@ fn adapt_request( // remove accept-encoding header so that pictrs doesnt compress the response const INVALID_HEADERS: &[HeaderName] = &[ACCEPT_ENCODING, HOST]; - let client_request = client.request(request.method().clone(), url); + let client_request = client + .request(request.method().clone(), url) + .timeout(REQWEST_TIMEOUT); request .headers() diff --git a/src/main.rs b/src/main.rs index 7f5946f5d..3fbd0c656 100644 --- a/src/main.rs +++ b/src/main.rs @@ -99,7 +99,7 @@ async fn main() -> Result<(), LemmyError> { settings.bind, settings.port ); - let client = Client::builder() + let reqwest_client = Client::builder() .user_agent(build_user_agent(&settings)) .timeout(REQWEST_TIMEOUT) .build()?; @@ -111,11 +111,16 @@ async fn main() -> Result<(), LemmyError> { backoff_exponent: 2, }; - let client = ClientBuilder::new(client) + let client = ClientBuilder::new(reqwest_client.clone()) .with(TracingMiddleware) .with(RetryTransientMiddleware::new_with_policy(retry_policy)) .build(); + // Pictrs cannot use the retry middleware + let pictrs_client = ClientBuilder::new(reqwest_client.clone()) + .with(TracingMiddleware) + .build(); + check_private_instance_and_federation_enabled(&pool, &settings).await?; let chat_server = ChatServer::startup( @@ -149,7 +154,7 @@ async fn main() -> Result<(), LemmyError> { .configure(|cfg| api_routes::config(cfg, &rate_limiter)) .configure(|cfg| lemmy_apub::http::routes::config(cfg, &settings)) .configure(feeds::config) - .configure(|cfg| images::config(cfg, client.clone(), &rate_limiter)) + .configure(|cfg| images::config(cfg, pictrs_client.clone(), &rate_limiter)) .configure(nodeinfo::config) .configure(|cfg| webfinger::config(cfg, &settings)) })