From c3b4f78daffd5217c7c57411dcb5addbbf84f38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugues=20Clou=C3=A2tre?= <15008125+clouatre@users.noreply.github.com> Date: Mon, 18 May 2026 10:15:42 -0400 Subject: [PATCH] fix(extension_manager): set TCP_USER_TIMEOUT on streamable HTTP clients (#9207) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hugues Clouâtre --- crates/goose/src/agents/extension_manager.rs | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/crates/goose/src/agents/extension_manager.rs b/crates/goose/src/agents/extension_manager.rs index cb2c88db46..02b4cb06b2 100644 --- a/crates/goose/src/agents/extension_manager.rs +++ b/crates/goose/src/agents/extension_manager.rs @@ -517,8 +517,13 @@ async fn connect_with_auth( ) -> ExtensionResult> { let mut auth_headers = HeaderMap::new(); auth_headers.insert(reqwest::header::USER_AGENT, GOOSE_USER_AGENT); - let auth_http_client = reqwest::Client::builder() - .default_headers(auth_headers) + #[allow(unused_mut)] + let mut auth_client_builder = reqwest::Client::builder().default_headers(auth_headers); + #[cfg(target_os = "linux")] + { + auth_client_builder = auth_client_builder.tcp_user_timeout(Some(timeout)); + } + let auth_http_client = auth_client_builder .build() .map_err(|_| ExtensionError::ConfigError("could not construct http client".to_string()))?; let auth_client = AuthClient::new(auth_http_client, auth_manager); @@ -587,8 +592,15 @@ async fn create_streamable_http_client( ); } - let http_client = reqwest::Client::builder() - .default_headers(default_headers) + let timeout_duration = Duration::from_secs(resolve_timeout(timeout)); + + #[allow(unused_mut)] + let mut http_client_builder = reqwest::Client::builder().default_headers(default_headers); + #[cfg(target_os = "linux")] + { + http_client_builder = http_client_builder.tcp_user_timeout(Some(timeout_duration)); + } + let http_client = http_client_builder .build() .map_err(|_| ExtensionError::ConfigError("could not construct http client".to_string()))?; @@ -597,8 +609,6 @@ async fn create_streamable_http_client( StreamableHttpClientTransportConfig::with_uri(uri), ); - let timeout_duration = Duration::from_secs(resolve_timeout(timeout)); - // If we have stored OAuth credentials, try refreshing and connecting directly. // This avoids the unnecessary 401 → browser re-auth cycle on every new session. let credential_store = GooseCredentialStore::new(name.to_string());