Skip to content

Commit

Permalink
More logging
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Nov 19, 2024
1 parent 950a81a commit 57a6f20
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
39 changes: 23 additions & 16 deletions crates/uv-client/src/base_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,48 +461,55 @@ impl RetryableStrategy for UvRetryableStrategy {
///
/// These cases should be safe to retry with [`Retryable::Transient`].
pub(crate) fn is_extended_transient_error(err: &dyn Error) -> bool {
// First, look for `WrappedReqwestError`, which wraps `reqwest::Error` but doesn't always
// include it in the source.
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`)");
}
}

// Next, look for `reqwest_middleware::Error`, which wraps `reqwest::Error`, but also includes
// errors from the middleware stack.
if let Some(err) = find_source::<reqwest_middleware::Error>(&err) {
} 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 connection reset or unexpected eof");
trace!("Cannot retry error: not one of `ConnectionReset` or `UnexpectedEof` (`reqwest_middleware::Error`)");
} else {
trace!("Cannot retry error: not an IO error");
trace!("Cannot retry error: not an IO error (`reqwest_middleware::Error`)");
}
}

// Finally, look for `reqwest::Error`, which is the most common error type.
if let Some(err) = find_source::<reqwest::Error>(&err) {
} 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 connection reset or unexpected eof");
trace!("Cannot retry error: not one of `ConnectionReset` or `UnexpectedEof` (`reqwest::Error`)");
} else {
trace!("Cannot retry error: not an IO error");
trace!("Cannot retry error: not an IO error (`reqwest::Error`)");
}
} else {
trace!("Cannot retry error: not a reqwest error");
}

trace!("Cannot retry error: not a reqwest error");
false
}

Expand Down
4 changes: 2 additions & 2 deletions crates/uv-client/src/cached_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ impl CachedClient {
let retry_decision = retry_policy.should_retry(start_time, n_past_retries);
if let reqwest_retry::RetryDecision::Retry { execute_after } = retry_decision {
debug!(
"Transient failure while handling response from {}; retrying: {err}",
"Transient failure while handling response from {}; retrying...",
req.url(),
);
let duration = execute_after
Expand Down Expand Up @@ -678,7 +678,7 @@ impl CachedClient {
let retry_decision = retry_policy.should_retry(start_time, n_past_retries);
if let reqwest_retry::RetryDecision::Retry { execute_after } = retry_decision {
debug!(
"Transient failure while handling response from {}; retrying: {err}",
"Transient failure while handling response from {}; retrying...",
req.url(),
);
let duration = execute_after
Expand Down

0 comments on commit 57a6f20

Please sign in to comment.