Correctness: SSE event stream has no backpressure handling #98

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

Severity: Medium

Location

crates/hero_aibroker_lib/src/sse.rs

Finding

The SSE event channel uses a bounded channel but doesn't handle backpressure when the client is slow:

let (tx, rx) = tokio::sync::mpsc::channel(100);

When the channel fills up:

  • tx.send() waits (blocking the async task)
  • This blocks the upstream provider response from being processed
  • Could cascade backpressure to the provider connection

Impact

  • Slow clients can block upstream connections
  • Memory pressure from buffered events
  • No mechanism to disconnect slow clients

Recommendation

  • Use try_send and disconnect clients that can't keep up
  • Add a configurable buffer size per client
  • Implement heartbeat/timeout for idle SSE connections
## Severity: Medium ## Location `crates/hero_aibroker_lib/src/sse.rs` ## Finding The SSE event channel uses a bounded channel but doesn't handle backpressure when the client is slow: ```rust let (tx, rx) = tokio::sync::mpsc::channel(100); ``` When the channel fills up: - `tx.send()` waits (blocking the async task) - This blocks the upstream provider response from being processed - Could cascade backpressure to the provider connection ## Impact - Slow clients can block upstream connections - Memory pressure from buffered events - No mechanism to disconnect slow clients ## Recommendation - Use `try_send` and disconnect clients that can't keep up - Add a configurable buffer size per client - Implement heartbeat/timeout for idle SSE connections
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#98
No description provided.