Retry all h2 errors (#16038)

The h2 errors, a specific type nested in reqwest errors, all look like
they shouldn't happen in regular operations and should be retried. This
covers all `io::Error`s going through h2 (i.e., only HTTP 2
connections).

Fixes https://github.com/astral-sh/uv/issues/15916
This commit is contained in:
konsti 2025-10-09 15:53:14 +02:00 committed by GitHub
parent d3dc451ee9
commit 5ee728b3e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 6 deletions

View File

@ -1029,12 +1029,12 @@ pub fn is_transient_network_error(err: &(dyn Error + 'static)) -> bool {
} }
trace!("Cannot retry nested reqwest error"); trace!("Cannot retry nested reqwest error");
} else if let Some(io_err) = source.downcast_ref::<io::Error>().or_else(|| { } else if source.downcast_ref::<h2::Error>().is_some() {
// h2 may hide an IO error inside. // All h2 errors look like errors that should be retried
source // https://github.com/astral-sh/uv/issues/15916
.downcast_ref::<h2::Error>() trace!("Retrying nested h2 error");
.and_then(|err| err.get_io()) return true;
}) { } else if let Some(io_err) = source.downcast_ref::<io::Error>() {
has_known_error = true; has_known_error = true;
let retryable_io_err_kinds = [ let retryable_io_err_kinds = [
// https://github.com/astral-sh/uv/issues/12054 // https://github.com/astral-sh/uv/issues/12054