rust.unbounded_retry
Stability
High
Detects retry loops without maximum attempt limits.
Why It Matters
Section titled “Why It Matters”Unbounded retries:
- Infinite loops — Never give up on permanent failures
- Amplify load — Retry storms overwhelm upstream
- Waste resources — CPU/network spent on hopeless retries
Example
Section titled “Example”// ❌ 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}What Unfault Detects
Section titled “What Unfault Detects”- Loop-based retries without counter
- Missing max_retries configuration
- No exponential backoff strategy
Auto-Fix
Section titled “Auto-Fix”Unfault can add retry limits using backoff crate.