diff --git a/Cargo.lock b/Cargo.lock index 7f87bce9c..ec9fa63cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4994,6 +4994,7 @@ dependencies = [ "assert_cmd", "assert_fs", "axoupdater", + "backon", "base64 0.22.1", "byteorder", "clap", diff --git a/crates/uv/Cargo.toml b/crates/uv/Cargo.toml index facb52a7a..f87089ffd 100644 --- a/crates/uv/Cargo.toml +++ b/crates/uv/Cargo.toml @@ -117,6 +117,7 @@ windows-result = { workspace = true } [dev-dependencies] assert_cmd = { workspace = true } assert_fs = { workspace = true } +backon = { workspace = true } base64 = { workspace = true } byteorder = { workspace = true } filetime = { workspace = true } diff --git a/crates/uv/tests/it/extract.rs b/crates/uv/tests/it/extract.rs index d1c9a8bd9..a3defd552 100644 --- a/crates/uv/tests/it/extract.rs +++ b/crates/uv/tests/it/extract.rs @@ -1,10 +1,22 @@ #![cfg(feature = "r2")] +use backon::{BackoffBuilder, Retryable}; use futures::TryStreamExt; use tokio_util::compat::FuturesAsyncReadCompatExt; async fn unzip(url: &str) -> anyhow::Result<(), uv_extract::Error> { - let response = reqwest::get(url).await.unwrap(); + let backoff = backon::ExponentialBuilder::default() + .with_min_delay(std::time::Duration::from_millis(500)) + .with_max_times(5) + .build(); + + let download = || async { + let response = reqwest::get(url).await?; + Ok::<_, reqwest::Error>(response) + }; + + let response = download.retry(backoff).await.unwrap(); + let reader = response .bytes_stream() .map_err(std::io::Error::other)