From 0f3acfe7342bd2d784f550c085b3c8034358522d Mon Sep 17 00:00:00 2001 From: sychic <47618543+Sychic@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:01:45 -0400 Subject: [PATCH 1/3] fix(app-lib): remove timeout for shared instance uploads --- .../app-lib/src/api/instance/shared/client.rs | 12 +++++++- .../app-lib/src/api/instance/shared/mod.rs | 5 +++- packages/app-lib/src/util/fetch.rs | 29 +++++++++++++++---- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/packages/app-lib/src/api/instance/shared/client.rs b/packages/app-lib/src/api/instance/shared/client.rs index 52fdc788cf..7452e99464 100644 --- a/packages/app-lib/src/api/instance/shared/client.rs +++ b/packages/app-lib/src/api/instance/shared/client.rs @@ -874,7 +874,7 @@ pub(super) async fn send_bytes_request_to_url( "Sending shared instances API request" ); - let mut request = shared_instances_client(url) + let mut request = shared_instances_upload_client(url) .request(method.clone(), url) .bearer_auth(credentials.session) .header(reqwest::header::CONTENT_TYPE, "application/octet-stream") @@ -1063,3 +1063,13 @@ pub(super) fn shared_instances_client( &INSECURE_REQWEST_CLIENT } } + +pub(super) fn shared_instances_upload_client( + base_url: &str, +) -> &'static reqwest::Client { + if base_url.starts_with("https://") { + &NO_TIMEOUT_REQWEST_CLIENT + } else { + &INSECURE_NO_TIMEOUT_REQWEST_CLIENT + } +} diff --git a/packages/app-lib/src/api/instance/shared/mod.rs b/packages/app-lib/src/api/instance/shared/mod.rs index b13cae82e8..7706a4f841 100644 --- a/packages/app-lib/src/api/instance/shared/mod.rs +++ b/packages/app-lib/src/api/instance/shared/mod.rs @@ -15,7 +15,10 @@ use crate::state::{ ContentSourceKind, EditInstance, ModLoader, ModrinthCredentials, ProjectType, SharedInstanceRole, State, }; -use crate::util::fetch::{INSECURE_REQWEST_CLIENT, REQWEST_CLIENT}; +use crate::util::fetch::{ + INSECURE_NO_TIMEOUT_REQWEST_CLIENT, INSECURE_REQWEST_CLIENT, + NO_TIMEOUT_REQWEST_CLIENT, REQWEST_CLIENT, +}; use chrono::{DateTime, Utc}; use reqwest::{Method, StatusCode}; use serde::de::DeserializeOwned; diff --git a/packages/app-lib/src/util/fetch.rs b/packages/app-lib/src/util/fetch.rs index 17c0ec002e..0179184647 100644 --- a/packages/app-lib/src/util/fetch.rs +++ b/packages/app-lib/src/util/fetch.rs @@ -330,28 +330,47 @@ fn duration_seconds_ceil(duration: Duration) -> u64 { .saturating_add(u64::from(duration.subsec_nanos() > 0)) } +fn reqwest_client_builder_with_timeout() -> reqwest::ClientBuilder { + reqwest_client_builder() + .read_timeout(Duration::from_secs(30)) +} + fn reqwest_client_builder() -> reqwest::ClientBuilder { reqwest::Client::builder() - .connect_timeout(time::Duration::from_secs(15)) - .read_timeout(time::Duration::from_secs(30)) - .tcp_keepalive(Some(time::Duration::from_secs(10))) + .connect_timeout(Duration::from_secs(15)) + .tcp_keepalive(Some(Duration::from_secs(10))) .user_agent(crate::launcher_user_agent()) } pub static INSECURE_REQWEST_CLIENT: LazyLock = LazyLock::new(|| { - reqwest_client_builder() + reqwest_client_builder_with_timeout() .build() .expect("client configuration should be valid") }); pub static REQWEST_CLIENT: LazyLock = LazyLock::new(|| { - reqwest_client_builder() + reqwest_client_builder_with_timeout() .https_only(true) .build() .expect("client configuration should be valid") }); +pub static INSECURE_NO_TIMEOUT_REQWEST_CLIENT: LazyLock = + LazyLock::new(|| { + reqwest_client_builder() + .build() + .expect("client configuration should be valid") + }); + +pub static NO_TIMEOUT_REQWEST_CLIENT: LazyLock = + LazyLock::new(|| { + reqwest_client_builder() + .https_only(true) + .build() + .expect("client configuration should be valid") + }); + const FETCH_ATTEMPTS: usize = 2; pub type FetchProgressFn<'a> = dyn FnMut( From 0fe196e21cfafa0a2547c033973a1fa5c97e191e Mon Sep 17 00:00:00 2001 From: sychic <47618543+Sychic@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:22:41 -0400 Subject: [PATCH 2/3] style(app-lib): cargo fmt --- packages/app-lib/src/util/fetch.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/app-lib/src/util/fetch.rs b/packages/app-lib/src/util/fetch.rs index 0179184647..b2801d4914 100644 --- a/packages/app-lib/src/util/fetch.rs +++ b/packages/app-lib/src/util/fetch.rs @@ -331,8 +331,7 @@ fn duration_seconds_ceil(duration: Duration) -> u64 { } fn reqwest_client_builder_with_timeout() -> reqwest::ClientBuilder { - reqwest_client_builder() - .read_timeout(Duration::from_secs(30)) + reqwest_client_builder().read_timeout(Duration::from_secs(30)) } fn reqwest_client_builder() -> reqwest::ClientBuilder { From b4b4e192f2190ba5cfe409f7a38edfd3b7f2419c Mon Sep 17 00:00:00 2001 From: sychic <47618543+Sychic@users.noreply.github.com> Date: Tue, 25 Aug 2026 13:39:33 -0400 Subject: [PATCH 3/3] style(app-lib): remove unused import --- packages/app-lib/src/util/fetch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app-lib/src/util/fetch.rs b/packages/app-lib/src/util/fetch.rs index b2801d4914..2730ca8d18 100644 --- a/packages/app-lib/src/util/fetch.rs +++ b/packages/app-lib/src/util/fetch.rs @@ -19,7 +19,7 @@ use std::num::NonZeroU32; use std::path::Path; use std::pin::Pin; use std::sync::{Arc, LazyLock}; -use std::time::{self, Duration, Instant, SystemTime}; +use std::time::{Duration, Instant, SystemTime}; use tokio::sync::Semaphore; use tokio::{fs::File, io::AsyncReadExt, io::AsyncWriteExt}; use tracing::{debug, info};