From 872fe8fef3870dcde9a907b4c22669ff4919bc6f Mon Sep 17 00:00:00 2001 From: silverpill Date: Wed, 22 Feb 2023 21:48:19 +0000 Subject: [PATCH] Set fetcher timeout to 3 minutes --- CHANGELOG.md | 4 ++++ src/activitypub/fetcher/fetchers.rs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fc82a6..dae900b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Added + +- Set fetcher timeout to 3 minutes. + ## [1.14.0] - 2023-02-22 ### Added diff --git a/src/activitypub/fetcher/fetchers.rs b/src/activitypub/fetcher/fetchers.rs index 4dc5d4e..71c7bfe 100644 --- a/src/activitypub/fetcher/fetchers.rs +++ b/src/activitypub/fetcher/fetchers.rs @@ -24,6 +24,7 @@ use crate::media::{save_file, SUPPORTED_MEDIA_TYPES}; use crate::webfinger::types::{ActorAddress, JsonResourceDescriptor}; const FETCHER_CONNECTION_TIMEOUT: u64 = 30; +const FETCHER_TIMEOUT: u64 = 180; #[derive(thiserror::Error, Debug)] pub enum FetchError { @@ -51,12 +52,14 @@ pub enum FetchError { fn build_client(instance: &Instance) -> reqwest::Result { let mut client_builder = Client::builder(); - let connect_timeout = Duration::from_secs(FETCHER_CONNECTION_TIMEOUT); if let Some(ref proxy_url) = instance.proxy_url { let proxy = Proxy::all(proxy_url)?; client_builder = client_builder.proxy(proxy); }; + let timeout = Duration::from_secs(FETCHER_TIMEOUT); + let connect_timeout = Duration::from_secs(FETCHER_CONNECTION_TIMEOUT); client_builder + .timeout(timeout) .connect_timeout(connect_timeout) .build() }