Skip to content

perf: add timeout wrapper for embedding calls #409

@bug-ops

Description

@bug-ops

Problem

Embedding calls have no timeout, relying on HTTP client defaults (30-60s). Slow/failed requests block skill matching indefinitely.

Files:

  • crates/zeph-core/src/agent/context.rs lines 632-642
  • crates/zeph-skills/src/matcher.rs lines 22-32

Current code:

let fut = embed_fn(&skill.description);  // No timeout

Impact

  • User-visible latency spike during network issues
  • Skill matching can hang for 30-60 seconds

Solution

use tokio::time::{timeout, Duration};

let fut = timeout(Duration::from_secs(10), embed_fn(&skill.description));
match fut.await {
    Ok(Ok(vec)) => Some((i, vec)),
    Ok(Err(e)) => { tracing::warn!("embed failed: {e:#}"); None }
    Err(_) => { tracing::warn!("embed timeout"); None }
}

Priority: P2
Effort: Small (1 hour)
Related to #391

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance optimization

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions