Skip to content

Commit

Permalink
Retry on tar extraction errors
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Dec 9, 2024
1 parent 13c4003 commit 6d6ed17
Showing 1 changed file with 9 additions and 44 deletions.
53 changes: 9 additions & 44 deletions crates/uv-client/src/base_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use uv_warnings::warn_user_once;
use crate::linehaul::LineHaul;
use crate::middleware::OfflineMiddleware;
use crate::tls::read_identity;
use crate::{Connectivity, WrappedReqwestError};
use crate::Connectivity;

pub const DEFAULT_RETRIES: u32 = 3;

Expand Down Expand Up @@ -458,51 +458,16 @@ impl RetryableStrategy for UvRetryableStrategy {
pub fn is_extended_transient_error(err: &dyn Error) -> bool {
trace!("Attempting to retry error: {err:?}");

if let Some(err) = find_source::<WrappedReqwestError>(&err) {
// First, look for `WrappedReqwestError`, which wraps `reqwest::Error` but doesn't always
// include it in the source.
if let Some(io) = find_source::<std::io::Error>(&err) {
if io.kind() == std::io::ErrorKind::ConnectionReset
|| io.kind() == std::io::ErrorKind::UnexpectedEof
{
trace!(
"Retrying error: `ConnectionReset` or `UnexpectedEof` (`WrappedReqwestError`)"
);
return true;
}
trace!("Cannot retry error: not one of `ConnectionReset` or `UnexpectedEof` (`WrappedReqwestError`)");
} else {
trace!("Cannot retry error: not an IO error (`WrappedReqwestError`)");
}
} else if let Some(err) = find_source::<reqwest_middleware::Error>(&err) {
// Next, look for `reqwest_middleware::Error`, which wraps `reqwest::Error`, but also
// includes errors from the middleware stack.
if let Some(io) = find_source::<std::io::Error>(&err) {
if io.kind() == std::io::ErrorKind::ConnectionReset
|| io.kind() == std::io::ErrorKind::UnexpectedEof
{
trace!("Retrying error: `ConnectionReset` or `UnexpectedEof` (`reqwest_middleware::Error`)");
return true;
}
trace!("Cannot retry error: not one of `ConnectionReset` or `UnexpectedEof` (`reqwest_middleware::Error`)");
} else {
trace!("Cannot retry error: not an IO error (`reqwest_middleware::Error`)");
}
} else if let Some(err) = find_source::<reqwest::Error>(&err) {
// Finally, look for `reqwest::Error`, which is the most common error type.
if let Some(io) = find_source::<std::io::Error>(&err) {
if io.kind() == std::io::ErrorKind::ConnectionReset
|| io.kind() == std::io::ErrorKind::UnexpectedEof
{
trace!("Retrying error: `ConnectionReset` or `UnexpectedEof` (`reqwest::Error`)");
return true;
}
trace!("Cannot retry error: not one of `ConnectionReset` or `UnexpectedEof` (`reqwest::Error`)");
} else {
trace!("Cannot retry error: not an IO error (`reqwest::Error`)");
if let Some(io) = find_source::<std::io::Error>(&err) {
if io.kind() == std::io::ErrorKind::ConnectionReset
|| io.kind() == std::io::ErrorKind::UnexpectedEof
{
trace!("Retrying error: `ConnectionReset` or `UnexpectedEof`");
return true;
}
trace!("Cannot retry error: not one of `ConnectionReset` or `UnexpectedEof`");
} else {
trace!("Cannot retry error: not a reqwest error");
trace!("Cannot retry error: not an IO error");
}

false
Expand Down

0 comments on commit 6d6ed17

Please sign in to comment.