Skip to content

rust.missing_select_timeout

Stability Medium

Detects tokio::select! without a timeout branch that can wait indefinitely.

Select without timeout:

  • Indefinite waiting — Can block forever if no branch completes
  • Resource leaks — Held resources never released
  • Stuck tasks — No recovery from stalled operations
// ❌ Before (no timeout)
tokio::select! {
result = operation_a() => handle_a(result),
result = operation_b() => handle_b(result),
}
// ✅ After (with timeout)
tokio::select! {
result = operation_a() => handle_a(result),
result = operation_b() => handle_b(result),
_ = tokio::time::sleep(Duration::from_secs(30)) => {
tracing::warn!("Operations timed out");
return Err(Error::Timeout);
}
}
  • tokio::select! without sleep or timeout branch
  • Long-running selects without bounds