Skip to content

rust.missing_async_timeout

Stability Medium

Detects async operations that can wait indefinitely without timeout bounds.

Missing timeouts:

  • Indefinite blocking — Operations never complete
  • Resource exhaustion — Connections held forever
  • Cascading failures — Stuck tasks affect other work
// ❌ Before (no timeout)
async fn fetch_data() -> Result<Data, Error> {
let response = client.get(url).send().await?;
Ok(response.json().await?)
}
// ✅ After (with timeout)
use tokio::time::timeout;
async fn fetch_data() -> Result<Data, Error> {
timeout(Duration::from_secs(30), async {
let response = client.get(url).send().await?;
Ok(response.json().await?)
})
.await
.map_err(|_| Error::Timeout)?
}
  • HTTP client calls without timeout
  • Database operations without bounds
  • Channel receives without timeout