Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry on tar extraction errors #9753

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading