{"record":{"id":"221b3482ef34b65d","repo":"BoundaryML/baml","slug":"bamlaborterror-operation-was-aborted-msg","errorCode":null,"errorMessage":"BamlAbortError: Operation was aborted: {msg}","messagePattern":"BamlAbortError: Operation was aborted: (.+?)","errorType":"exception","errorClass":"BamlAbortError","httpStatus":null,"severity":"warning","filePath":"engine/language_client_typescript/src/errors.rs","lineNumber":128,"sourceCode":"                        failed.client.as_str(),\n                        failed.message.as_str(),\n                        &failed.code,\n                        None,\n                        failed.raw_response.as_deref(),\n                    )\n                }\n            },\n            LLMResponse::UserFailure(msg) => napi::Error::new(\n                napi::Status::GenericFailure,\n                format!(\"BamlError: BamlInvalidArgumentError: {msg}\"),\n            ),\n            LLMResponse::InternalFailure(_) => napi::Error::new(\n                napi::Status::GenericFailure,\n                format!(\n                    \"BamlError: BamlClientError: Something went wrong with the LLM client: {err}\"\n                ),\n            ),\n            LLMResponse::Cancelled(msg) => napi::Error::new(\n                napi::Status::GenericFailure,\n                format!(\"BamlAbortError: Operation was aborted: {msg}\"),\n            ),\n        }\n    } else {\n        napi::Error::new(napi::Status::GenericFailure, format!(\"BamlError: {err:?}\"))\n    }\n}\n\nfn throw_baml_validation_error(\n    prompt: &str,\n    raw_output: &str,\n    message: &str,\n    detailed_message: Option<&str>,\n) -> napi::Error {\n    let error_json = serde_json::json!({\n        \"type\": \"BamlValidationError\",\n        \"prompt\": prompt,","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_typescript/src/errors.rs#L110-L146","documentation":"BamlAbortError indicates the LLM call was cancelled: from_anyhow_error maps LLMResponse::Cancelled to this message. It signals the request was aborted (by the caller or the runtime) rather than failing at the provider.","triggerScenarios":"Aborting an in-flight generated-function call (AbortSignal / cancellation token), dropping the awaiting task, or the runtime cancelling the request so the driver returns LLMResponse::Cancelled.","commonSituations":"Users cancel a request in the UI and the app propagates the abort; request timeouts implemented via AbortController; server shutdown mid-call.","solutions":["Check whether your own code (AbortController, request cancellation) triggered the abort","If the abort is unexpected, review timeout/shutdown handling around the BAML call","Re-run the request; aborted calls are safe to retry","If aborts are legitimate, catch BamlAbortError and treat it as a user-initiated cancellation"],"exampleFix":"// before\nconst result = await b.MyFunction(args); // caller abort propagates as thrown error\n// after\ntry {\n  const result = await b.MyFunction(args);\n} catch (e) {\n  if (String(e).startsWith('BamlAbortError')) return null; // treat as cancellation\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// ensure the AbortSignal is still alive before the call\nif (signal?.aborted) return null;","typeGuard":"const isAbortError = (e: unknown): boolean => String(e).startsWith('BamlAbortError');","tryCatchPattern":"try {\n  const result = await b.MyFunction(args, { abortSignal });\n} catch (e) {\n  if (isAbortError(e)) return null; // user cancellation, not a failure\n  throw e;\n}","preventionTips":["Treat BamlAbortError as user-initiated cancellation, not a bug","Reuse a single AbortController per logical request and only abort it deliberately","Add retries only for non-abort failures","Log aborts at info level to distinguish them from real errors"],"tags":["cancellation","abort","llm","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"}