{"record":{"id":"1304ac0f1e60d073","repo":"BoundaryML/baml","slug":"request-timed-out-after-0","errorCode":null,"errorMessage":"Request timed out after {0:?}","messagePattern":"Request timed out after (.+?)","errorType":"exception","errorClass":"ApiError","httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/tracingv2/publisher/publisher.rs","lineNumber":201,"sourceCode":"        match timeout(timeout_duration, fut).await {\n            Ok(res) => res,\n            Err(_) => Err(ApiError::Timeout(timeout_duration)),\n        }\n    }\n}\n\n#[derive(thiserror::Error, Debug)]\npub enum ApiError {\n    #[error(\"Transport error: {0}\")]\n    Transport(reqwest::Error),\n    #[error(\"HTTP error: {status} {body}\")]\n    Http {\n        status: reqwest::StatusCode,\n        body: String,\n    },\n    #[error(\"Failed to deserialize response: {0}\")]\n    Deserialize(serde_json::Error),\n    #[error(\"Request timed out after {0:?}\")]\n    Timeout(Duration),\n}\n\nimpl TypeLookup for RuntimeAST {\n    fn type_lookup(&self, name: &str) -> Option<Arc<baml_rpc::BamlTypeId>> {\n        self.ast.type_lookup(name)\n    }\n\n    fn function_lookup(&self, name: &str) -> Option<Arc<baml_rpc::ast::tops::BamlFunctionId>> {\n        self.ast.function_lookup(name)\n    }\n\n    fn baml_src_hash(&self) -> Option<String> {\n        self.ast.baml_src_hash()\n    }\n}\n\nimpl BlobStorage for RuntimeAST {","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/tracingv2/publisher/publisher.rs#L183-L219","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlet client = reqwest::Client::new();\n// after\nlet client = reqwest::Client::builder()\n    .timeout(Duration::from_secs(60))\n    .build()?;","handlingStrategy":"retry","validationCode":"// measure collector latency before setting timeouts\ntimeit(lambda: requests.post(f\"{BAML_URL}/v1/events\", headers=auth, json=payload), number=3)","typeGuard":"fn is_timeout_err(e: &ApiError) -> bool { matches!(e, ApiError::Timeout(_)) }","tryCatchPattern":"match publisher.publish(ev) {\n    Err(ApiError::Timeout(d)) => {\n        log::warn!(\"publish timed out after {d:?}; retrying with backoff\");\n        retry_with_backoff();\n    }\n    Err(e) => log::error!(\"publish failed: {e}\"),\n    Ok(_) => {}\n}","preventionTips":["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"],"tags":["timeout","network","baml","tracing"],"backgroundTag":"request-timeout","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}