BoundaryML/baml · error · ApiError
Request timed out after {0:?}
Error message
Request timed out after {0:?} What it means
This is the Display message of ApiError::Timeout in the BAML trace publisher. It is thrown when the HTTP request to the BAML tracing API (trace publish or source upload) exceeded the configured request timeout duration without completing. The library applies an explicit timeout so stalled connections do not hang the application's flush.
Source
Thrown at engine/baml-runtime/src/tracingv2/publisher/publisher.rs:201
match timeout(timeout_duration, fut).await {
Ok(res) => res,
Err(_) => Err(ApiError::Timeout(timeout_duration)),
}
}
}
#[derive(thiserror::Error, Debug)]
pub enum ApiError {
#[error("Transport error: {0}")]
Transport(reqwest::Error),
#[error("HTTP error: {status} {body}")]
Http {
status: reqwest::StatusCode,
body: String,
},
#[error("Failed to deserialize response: {0}")]
Deserialize(serde_json::Error),
#[error("Request timed out after {0:?}")]
Timeout(Duration),
}
impl TypeLookup for RuntimeAST {
fn type_lookup(&self, name: &str) -> Option<Arc<baml_rpc::BamlTypeId>> {
self.ast.type_lookup(name)
}
fn function_lookup(&self, name: &str) -> Option<Arc<baml_rpc::ast::tops::BamlFunctionId>> {
self.ast.function_lookup(name)
}
fn baml_src_hash(&self) -> Option<String> {
self.ast.baml_src_hash()
}
}
impl BlobStorage for RuntimeAST {View on GitHub (pinned to bd85ce9dee)
Solutions
- Increase the publisher's request/flush timeout duration.
- Reduce upload size (trim baml_src payload) or check network bandwidth.
- Verify the collector endpoint is responsive (curl timing).
- Add retry with backoff for transient timeouts.
Example fix
// before
let client = reqwest::Client::new();
// after
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(60))
.build()?; Defensive patterns
Strategy: retry
Validate before calling
// measure collector latency before setting timeouts
timeit(lambda: requests.post(f"{BAML_URL}/v1/events", headers=auth, json=payload), number=3) Type guard
fn is_timeout_err(e: &ApiError) -> bool { matches!(e, ApiError::Timeout(_)) } Try / catch
match publisher.publish(ev) {
Err(ApiError::Timeout(d)) => {
log::warn!("publish timed out after {d:?}; retrying with backoff");
retry_with_backoff();
}
Err(e) => log::error!("publish failed: {e}"),
Ok(_) => {}
} Prevention
- Set client timeouts generously (30-60s) for large uploads
- Retry timeouts with exponential backoff
- Monitor collector latency and alert on degradation
- Avoid flushing huge payloads at once; batch smaller
When it happens
Trigger: The reqwest request to the collector did not complete within the configured timeout (Duration is included in the message): slow network, unresponsive server, or an oversized baml_src upload payload on a slow link.
Common situations: Large AST uploads over slow connections, collector service hanging under load, high-latency links from remote CI runners, or an overly tight timeout configured for the publisher.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- timeout: {message}
- Transport error: {0}
- Blob flush timed out after {:?}
- Flush timed out after {:?}
- baml.panics.Cancelled
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/1304ac0f1e60d073.
Report an issue: GitHub.