{"record":{"id":"c7e3563970c2ac69","repo":"BoundaryML/baml","slug":"bamlerror-bamlclienterror-bamltimeouterror-message","errorCode":null,"errorMessage":"BamlError: BamlClientError: BamlTimeoutError: {message}","messagePattern":"BamlError: BamlClientError: BamlTimeoutError: (.+?)","errorType":"exception","errorClass":"BamlTimeoutError","httpStatus":null,"severity":"error","filePath":"engine/language_client_typescript/src/errors.rs","lineNumber":204,"sourceCode":"    });\n    napi::Error::new(napi::Status::GenericFailure, error_json.to_string())\n}\n\nfn throw_baml_abort_error(detailed_message: Option<&str>) -> napi::Error {\n    let error_json = serde_json::json!({\n        \"type\": \"BamlAbortError\",\n        \"detailed_message\": detailed_message,\n    });\n    napi::Error::new(napi::Status::GenericFailure, error_json.to_string())\n}\n\nfn throw_baml_timeout_error(client_name: &str, message: &str) -> napi::Error {\n    let error_json = serde_json::json!({\n        \"type\": \"BamlTimeoutError\",\n        \"client_name\": client_name,\n        \"message\": format!(\"BamlError: BamlClientError: BamlTimeoutError: {}\", message),\n    });\n    napi::Error::new(napi::Status::GenericFailure, error_json.to_string())\n}\n","sourceCodeStart":186,"sourceCodeEnd":206,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_typescript/src/errors.rs#L186-L206","documentation":"BamlTimeoutError is thrown by throw_baml_timeout_error when the LLM client exceeds its configured timeout. The error JSON includes client_name and message; the timeout is per-client in the BAML config.","triggerScenarios":"A provider request exceeds the client's timeout setting in baml_src; slow streaming, hung connections, or an unreasonably small timeout value.","commonSituations":"Long generations with large max_tokens, provider latency spikes, corporate proxies adding latency, or a default timeout too low for heavy workloads.","solutions":["Increase the timeout in the client options (e.g. timeout 120s)","Check provider status / network latency for the affected client","Reduce output size (max_tokens, prompt length) to shorten request duration","Add a retry policy so timeouts trigger a fresh attempt"],"exampleFix":"// before\nclient GPT4 { provider openai options { model gpt-4 timeout 10s } }\n// after\nclient GPT4 { provider openai options { model gpt-4 timeout 120s } retry_policy Exponential }","handlingStrategy":"retry","validationCode":"// ensure a sane timeout is configured before long calls\nif (clientConfig.timeoutMs && clientConfig.timeoutMs < expectedDurationMs) console.warn('BAML client timeout likely too small');","typeGuard":"const isBamlTimeoutError = (e: unknown): boolean => String(e).includes('BamlTimeoutError');","tryCatchPattern":"try {\n  return await b.MyFunction(args);\n} catch (e) {\n  if (isBamlTimeoutError(e)) {\n    await sleep(1000);\n    return await b.MyFunction(args); // retry once on timeout\n  }\n  throw e;\n}","preventionTips":["Set timeout proportional to expected generation length (e.g. 60-120s)","Pair timeouts with a retry_policy","Reduce max_tokens/prompt size for latency-sensitive paths","Monitor p95 latency per client and tune timeouts from data"],"tags":["timeout","llm","network","typescript"],"backgroundTag":"request-timeout","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}