Skip to content

chang 1 tries to 1 try #15328

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

Merged
merged 1 commit into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions src/cargo/util/network/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ impl<'a> Retry<'a> {
.downcast_ref::<HttpNotSuccessful>()
.map(|http_err| http_err.display_short())
.unwrap_or_else(|| e.root_cause().to_string());
let left_retries = self.max_retries - self.retries;
let msg = format!(
"spurious network error ({} tries remaining): {err_msg}",
self.max_retries - self.retries,
"spurious network error ({} {} remaining): {err_msg}",
left_retries,
if left_retries != 1 { "tries" } else { "try" }
);
if let Err(e) = self.gctx.shell().warn(msg) {
return RetryResult::Err(e);
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/git_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ fn net_err_suggests_fetch_with_cli() {
[UPDATING] git repository `ssh://needs-proxy.invalid/git`
[WARNING] spurious network error (3 tries remaining): [..] resolve [..] needs-proxy.invalid: [..] known[..]
[WARNING] spurious network error (2 tries remaining): [..] resolve [..] needs-proxy.invalid: [..] known[..]
[WARNING] spurious network error (1 tries remaining): [..] resolve [..] needs-proxy.invalid: [..] known[..]
[WARNING] spurious network error (1 try remaining): [..] resolve [..] needs-proxy.invalid: [..] known[..]
[ERROR] failed to get `foo` as a dependency of package `foo v0.0.0 ([ROOT]/foo)`
Caused by:
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/net_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn net_retry_loads_from_config() {
.with_status(101)
.with_stderr_data(str![[r#"
...
[WARNING] spurious network error (1 tries remaining): [..]
[WARNING] spurious network error (1 try remaining): [..]
...
"#]])
.run();
Expand Down Expand Up @@ -71,7 +71,7 @@ fn net_retry_git_outputs_warning() {
.with_stderr_data(str![[r#"
...
[WARNING] spurious network error (2 tries remaining): [..]
[WARNING] spurious network error (1 tries remaining): [..]
[WARNING] spurious network error (1 try remaining): [..]
...
"#]])
.run();
Expand Down
14 changes: 8 additions & 6 deletions tests/testsuite/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3695,11 +3695,12 @@ fn sparse_retry_multiple() {
let remain = 3 - retry;
write!(
&mut expected,
"[WARNING] spurious network error ({remain} tries remaining): \
"[WARNING] spurious network error ({remain} {} remaining): \
failed to get successful HTTP response from \
`http://127.0.0.1:[..]/{ab}/{cd}/{name}` (127.0.0.1), got 500\n\
body:\n\
internal server error\n"
internal server error\n",
if remain != 1 { "tries" } else { "try" }
)
.unwrap();
}
Expand Down Expand Up @@ -3847,11 +3848,12 @@ fn dl_retry_multiple() {
let remain = 3 - retry;
write!(
&mut expected,
"[WARNING] spurious network error ({remain} tries remaining): \
"[WARNING] spurious network error ({remain} {} remaining): \
failed to get successful HTTP response from \
`http://127.0.0.1:[..]/dl/{name}/1.0.0/download` (127.0.0.1), got 500\n\
body:\n\
internal server error\n"
internal server error\n",
if remain != 1 { "tries" } else { "try" }
)
.unwrap();
}
Expand Down Expand Up @@ -4220,7 +4222,7 @@ Please slow down
[WARNING] spurious network error (2 tries remaining): failed to get successful HTTP response from `http://127.0.0.1:[..]/index/3/b/bar` (127.0.0.1), got 503
body:
Please slow down
[WARNING] spurious network error (1 tries remaining): failed to get successful HTTP response from `http://127.0.0.1:[..]/index/3/b/bar` (127.0.0.1), got 503
[WARNING] spurious network error (1 try remaining): failed to get successful HTTP response from `http://127.0.0.1:[..]/index/3/b/bar` (127.0.0.1), got 503
body:
Please slow down
[ERROR] failed to get `bar` as a dependency of package `foo v0.1.0 ([ROOT]/foo)`
Expand Down Expand Up @@ -4285,7 +4287,7 @@ Please slow down
[WARNING] spurious network error (2 tries remaining): failed to get successful HTTP response from `http://127.0.0.1:[..]/dl/bar/1.0.0/download` (127.0.0.1), got 503
body:
Please slow down
[WARNING] spurious network error (1 tries remaining): failed to get successful HTTP response from `http://127.0.0.1:[..]/dl/bar/1.0.0/download` (127.0.0.1), got 503
[WARNING] spurious network error (1 try remaining): failed to get successful HTTP response from `http://127.0.0.1:[..]/dl/bar/1.0.0/download` (127.0.0.1), got 503
body:
Please slow down
[ERROR] failed to download from `http://127.0.0.1:[..]/dl/bar/1.0.0/download`
Expand Down