diff --git a/crates/uv-client/src/registry_client.rs b/crates/uv-client/src/registry_client.rs index c83569f75..2570b6439 100644 --- a/crates/uv-client/src/registry_client.rs +++ b/crates/uv-client/src/registry_client.rs @@ -88,17 +88,17 @@ impl RegistryClientBuilder { pub fn build(self) -> RegistryClient { let client_raw = self.client.unwrap_or_else(|| { - // Get pip timeout from env var + // Timeout options, matching https://doc.rust-lang.org/nightly/cargo/reference/config.html#httptimeout + // `UV_REQUEST_TIMEOUT` is provided for backwards compatibility with v0.1.6 let default_timeout = 5 * 60; - let timeout = env::var("UV_REQUEST_TIMEOUT") - .map_err(|_| default_timeout) - .and_then(|value| { - value.parse::() - .map_err(|_| { - warn_user_once!("Ignoring invalid value for UV_REQUEST_TIMEOUT. Expected integer number of seconds, got {value}."); - default_timeout - }) - }).unwrap_or(default_timeout); + let timeout = env::var("UV_HTTP_TIMEOUT").or_else(|_| env::var("UV_REQUEST_TIMEOUT")).or_else(|_| env::var("HTTP_TIMEOUT")).and_then(|value| { + value.parse::() + .or_else(|_| { + // On parse error, warn and use the default timeout + warn_user_once!("Ignoring invalid value from environment for UV_REQUEST_TIMEOUT. Expected integer number of seconds, got \"{value}\"."); + Ok(default_timeout) + }) + }).unwrap_or(default_timeout); debug!("Using registry request timeout of {}s", timeout); // Disallow any connections. let client_core = ClientBuilder::new()