Skip to content
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
8 changes: 6 additions & 2 deletions crates/uv-client/src/base_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ pub struct RetryState {
}

impl RetryState {
/// Initialize the [`RetryState`] and start the backoff timer.
/// Initialize the [`RetryState`] and record the start time for the retry policy.
pub fn start(retry_policy: ExponentialBackoff, url: impl Into<DisplaySafeUrl>) -> Self {
Self {
retry_policy,
Expand Down Expand Up @@ -1314,12 +1314,16 @@ impl RetryState {
self.total_retries += error_retries;
match retryable_on_request_failure(err) {
Some(Retryable::Transient) => {
// Capture `now` before calling the policy so that `execute_after`
// (computed from a `SystemTime::now()` inside the library) is always
// >= `now`, making `duration_since` reliable.
let now = SystemTime::now();
let retry_decision = self
.retry_policy
.should_retry(self.start_time, self.total_retries);
if let reqwest_retry::RetryDecision::Retry { execute_after } = retry_decision {
let duration = execute_after
.duration_since(SystemTime::now())
.duration_since(now)
.unwrap_or_else(|_| Duration::default());

self.total_retries += 1;
Expand Down
Loading