Skip to content

Commit

Permalink
fix: remove hardcoded retries (foundry-rs#8141)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jun 12, 2024
1 parent 481c74b commit f816059
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions crates/common/src/provider/tower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<S> tower::layer::Layer<S> for RetryBackoffLayer {
inner,
policy: RateLimitRetryPolicy,
max_rate_limit_retries: self.max_rate_limit_retries,
max_timeout_retries: self.max_timeout_retries,
_max_timeout_retries: self.max_timeout_retries,
initial_backoff: self.initial_backoff,
compute_units_per_second: self.compute_units_per_second,
requests_enqueued: Arc::new(AtomicU32::new(0)),
Expand All @@ -74,7 +74,7 @@ pub struct RetryBackoffService<S> {
/// The maximum number of retries for rate limit errors
max_rate_limit_retries: u32,
/// The maximum number of retries for timeout errors
max_timeout_retries: u32,
_max_timeout_retries: u32,
/// The initial backoff in milliseconds
initial_backoff: u64,
/// The number of compute units per second for this service
Expand All @@ -100,7 +100,6 @@ impl tower::Service<RequestPacket> for RetryBackoffService<RuntimeTransport> {
Box::pin(async move {
let ahead_in_queue = this.requests_enqueued.fetch_add(1, Ordering::SeqCst) as u64;
let mut rate_limit_retry_number: u32 = 0;
let mut timeout_retries: u32 = 0;
loop {
let err;
let fut = this.inner.call(request.clone()).await;
Expand Down Expand Up @@ -157,11 +156,7 @@ impl tower::Service<RequestPacket> for RetryBackoffService<RuntimeTransport> {

tokio::time::sleep(total_backoff).await;
} else {
if timeout_retries < this.max_timeout_retries {
timeout_retries += 1;
continue;
}

trace!("encountered non retryable error {err:?}");
this.requests_enqueued.fetch_sub(1, Ordering::SeqCst);
return Err(err)
}
Expand Down

0 comments on commit f816059

Please sign in to comment.