From dbe6a214862d4bd86ff5eecd91921ee77848e610 Mon Sep 17 00:00:00 2001 From: konsti Date: Mon, 21 Jul 2025 00:28:34 +0200 Subject: [PATCH] Retry request on invalid data error (#14703) I also improved the trace logging. Fixes #14699 --- crates/uv-client/src/base_client.rs | 30 ++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/crates/uv-client/src/base_client.rs b/crates/uv-client/src/base_client.rs index 9ddc30e75..d901f57e7 100644 --- a/crates/uv-client/src/base_client.rs +++ b/crates/uv-client/src/base_client.rs @@ -920,18 +920,34 @@ pub fn is_extended_transient_error(err: &dyn Error) -> bool { } // IO Errors may be nested through custom IO errors. + let mut has_io_error = false; for io_err in find_sources::(&err) { - if io_err.kind() == io::ErrorKind::ConnectionReset - || io_err.kind() == io::ErrorKind::UnexpectedEof - || io_err.kind() == io::ErrorKind::BrokenPipe - { - trace!("Retrying error: `ConnectionReset` or `UnexpectedEof`"); + has_io_error = true; + let retryable_io_err_kinds = [ + // https://github.com/astral-sh/uv/issues/12054 + io::ErrorKind::BrokenPipe, + // From reqwest-middleware + io::ErrorKind::ConnectionAborted, + // https://github.com/astral-sh/uv/issues/3514 + io::ErrorKind::ConnectionReset, + // https://github.com/astral-sh/uv/issues/14699 + io::ErrorKind::InvalidData, + // https://github.com/astral-sh/uv/issues/9246 + io::ErrorKind::UnexpectedEof, + ]; + if retryable_io_err_kinds.contains(&io_err.kind()) { + trace!("Retrying error: `{}`", io_err.kind()); return true; } - trace!("Cannot retry IO error: not one of `ConnectionReset` or `UnexpectedEof`"); + trace!( + "Cannot retry IO error `{}`, not a retryable IO error kind", + io_err.kind() + ); } - trace!("Cannot retry error: not an IO error"); + if !has_io_error { + trace!("Cannot retry error: not an extended IO error"); + } false }