Skip to content

rust.unbounded_retry

Stability High

Detects retry loops without maximum attempt limits.

Unbounded retries:

  • Infinite loops — Never give up on permanent failures
  • Amplify load — Retry storms overwhelm upstream
  • Waste resources — CPU/network spent on hopeless retries
// ❌ Before (unbounded retry)
async fn fetch_data() -> Data {
loop {
match client.get("/data").send().await {
Ok(data) => return data,
Err(_) => tokio::time::sleep(Duration::from_secs(1)).await,
}
}
}
// ✅ After (with max retries and backoff)
use backoff::ExponentialBackoff;
async fn fetch_data() -> Result<Data, Error> {
let backoff = ExponentialBackoff {
max_elapsed_time: Some(Duration::from_secs(60)),
..Default::default()
};
backoff::future::retry(backoff, || async {
client.get("/data").send().await
.map_err(backoff::Error::transient)
}).await
}
  • Loop-based retries without counter
  • Missing max_retries configuration
  • No exponential backoff strategy

Unfault can add retry limits using backoff crate.