Operational: Catalog refresh spawns unbounded background tasks #124

Open
opened 2026-05-11 23:09:00 +00:00 by thabeta · 0 comments
Owner

Severity: Medium

Location

crates/hero_aibroker_server/src/main.rs — catalog refresh loop

Finding

For each configured provider and the OpenRouter catalog, a separate tokio::spawn creates a background refresh task:

for cat in &config.provider_catalogs {
    let cat = cat.clone();
    tokio::spawn(async move {
        // ... infinite loop with ticker
    });
}
  • No limit on number of spawned tasks
  • No way to stop or restart tasks
  • No error handling for task panics
  • If a catalog refresh task panics, it's silently lost

Impact

  • Unbounded task growth with many providers
  • No visibility into refresh task health
  • Panicked tasks are never restarted
  • Cannot gracefully shut down catalog refreshes

Recommendation

  • Use a structured task manager with lifecycle control
  • Add panic recovery for background tasks
  • Limit concurrent catalog fetches
  • Add health check for catalog freshness
  • Graceful shutdown for background tasks
## Severity: Medium ## Location `crates/hero_aibroker_server/src/main.rs` — catalog refresh loop ## Finding For each configured provider and the OpenRouter catalog, a separate `tokio::spawn` creates a background refresh task: ```rust for cat in &config.provider_catalogs { let cat = cat.clone(); tokio::spawn(async move { // ... infinite loop with ticker }); } ``` - No limit on number of spawned tasks - No way to stop or restart tasks - No error handling for task panics - If a catalog refresh task panics, it's silently lost ## Impact - Unbounded task growth with many providers - No visibility into refresh task health - Panicked tasks are never restarted - Cannot gracefully shut down catalog refreshes ## Recommendation - Use a structured task manager with lifecycle control - Add panic recovery for background tasks - Limit concurrent catalog fetches - Add health check for catalog freshness - Graceful shutdown for background tasks
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#124
No description provided.