Operational: TCP accept loop discards errors — no backoff on failure #88

Open
opened 2026-05-11 13:48:52 +00:00 by thabeta · 0 comments
Owner

Severity: Medium

Location

crates/hero_aibroker_server/src/main.rstcp_accept_loop() and accept_loop()

Finding

Both accept loops use ? to propagate errors, which will terminate the entire server on any accept failure:

async fn tcp_accept_loop(listener: TcpListener, app: Router) -> anyhow::Result<()> {
    loop {
        let (stream, _) = listener.accept().await?;  // any error kills the loop
        // ...
    }
}

Additionally, individual connection handling swallows errors:

let _ = hyper::server::conn::http1::Builder::new()
    .serve_connection(io, hyper_svc)
    .await;

Impact

  • A single accept error (e.g., EMFILE, ENFILE) kills the entire TCP listener
  • No distinction between transient and permanent errors
  • No backoff or recovery

Recommendation

  • Log and continue on transient accept errors (EMFILE, ECONNABORTED)
  • Only exit on permanent errors
  • Add exponential backoff for resource exhaustion scenarios
## Severity: Medium ## Location `crates/hero_aibroker_server/src/main.rs` — `tcp_accept_loop()` and `accept_loop()` ## Finding Both accept loops use `?` to propagate errors, which will terminate the entire server on any accept failure: ```rust async fn tcp_accept_loop(listener: TcpListener, app: Router) -> anyhow::Result<()> { loop { let (stream, _) = listener.accept().await?; // any error kills the loop // ... } } ``` Additionally, individual connection handling swallows errors: ```rust let _ = hyper::server::conn::http1::Builder::new() .serve_connection(io, hyper_svc) .await; ``` ## Impact - A single accept error (e.g., EMFILE, ENFILE) kills the entire TCP listener - No distinction between transient and permanent errors - No backoff or recovery ## Recommendation - Log and continue on transient accept errors (EMFILE, ECONNABORTED) - Only exit on permanent errors - Add exponential backoff for resource exhaustion scenarios
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_aibroker#88
No description provided.