From cde48c8ac8eb13e8eff5cfb5c9fc39dad69c4f19 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 24 Mar 2026 07:57:29 -0400 Subject: [PATCH] Fallback to direct download when direct URL streaming is unsupported (#18688) ## Summary Closes https://github.com/astral-sh/uv/issues/18620. --- .../src/distribution_database.rs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/uv-distribution/src/distribution_database.rs b/crates/uv-distribution/src/distribution_database.rs index 226740897..c3e0f4f32 100644 --- a/crates/uv-distribution/src/distribution_database.rs +++ b/crates/uv-distribution/src/distribution_database.rs @@ -248,8 +248,8 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> { return Err(Error::Extract(name, err)); } - // If the request failed because streaming is unsupported, download the - // wheel directly. + // If the request failed because streaming was unsupported or failed, + // download the wheel directly. let archive = self .download_wheel( url, @@ -314,13 +314,19 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> { cache: CacheInfo::default(), build: None, }), - Err(Error::Client(err)) if err.is_http_streaming_unsupported() => { - warn!( - "Streaming unsupported for {dist}; downloading wheel to disk ({err})" - ); + Err(Error::Extract(name, err)) => { + if err.is_http_streaming_unsupported() { + warn!( + "Streaming unsupported for {dist}; downloading wheel to disk ({err})" + ); + } else if err.is_http_streaming_failed() { + warn!("Streaming failed for {dist}; downloading wheel to disk ({err})"); + } else { + return Err(Error::Extract(name, err)); + } - // If the request failed because streaming is unsupported, download the - // wheel directly. + // If the request failed because streaming was unsupported or failed, + // download the wheel directly. let archive = self .download_wheel( wheel.url.raw().clone(),