{"record":{"id":"b02dd254517f075c","repo":"BoundaryML/baml","slug":"32800-request-canceled-0","errorCode":"-32800","errorMessage":"Request canceled: {0}","messagePattern":"Request canceled: (.+?)","errorType":"error_code","errorClass":"LspError","httpStatus":null,"severity":"info","filePath":"baml_language/crates/baml_lsp/src/error.rs","lineNumber":42,"sourceCode":"    /// Bounded transport backpressure (LSP `RequestFailed`, `-32803`).\n    #[error(\"LSP outbound sink is saturated\")]\n    OutboundSaturated,\n    /// A frame larger than the transport limit (LSP `RequestFailed`,\n    /// `-32803`).\n    #[error(\"LSP outbound frame exceeds the transport limit\")]\n    OutboundOversized,\n    #[error(\"Invalid command arguments for command: {command}: {message}\")]\n    InvalidCommandArguments { command: String, message: String },\n    #[error(\"File not found: {}\", .0.display())]\n    FileNotFound(PathBuf),\n    #[error(\"Path is invalid: {}: {message}\", path.display())]\n    InvalidPath { path: PathBuf, message: String },\n    /// The document's path is under no known source root.\n    #[error(\"No source root contains {}\", .0.display())]\n    NoRootForPath(PathBuf),\n    /// Cancellation claimed the response while the request was queued or\n    /// running (LSP `RequestCanceled`, `-32800`).\n    #[error(\"Request canceled: {0}\")]\n    RequestCanceled(String),\n    /// The request's snapshot became stale under an applied source change\n    /// (LSP `ContentModified`, `-32801`).\n    #[error(\"Content modified: {0}\")]\n    ContentModified(String),\n    /// A valid request that cannot be served right now (LSP `RequestFailed`,\n    /// `-32803`).\n    #[error(\"{0}\")]\n    RequestFailed(String),\n    /// Violated invariants, panics, serialization (LSP `InternalError`,\n    /// `-32603`).\n    #[error(\"Internal error: {0}\")]\n    Internal(String),\n    /// Malformed params, position, or range (LSP `InvalidParams`, `-32602`).\n    #[error(\"Invalid params: {0}\")]\n    InvalidParams(String),\n    /// A request before `initialize` completed (LSP `ServerNotInitialized`,\n    /// `-32002`).","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp/src/error.rs#L24-L60","documentation":"LspError::RequestCanceled reports that a cancellation (the LSP $/cancelRequest notification) claimed a response while the request was still queued or running. The message carries a human-readable reason string. It maps to the LSP RequestCanceled code -32800, telling the client the request did not complete because the client itself (or the server's policy) canceled it.","triggerScenarios":"The client sends $/cancelRequest for an in-flight request id; the user types quickly and the editor cancels superseded hover/completion requests; a client timeout wrapper cancels the request id.","commonSituations":"Rapid typing causing completion requests to be canceled and re-issued; editors canceling diagnostic requests when a document changes; users closing files while requests are pending.","solutions":["Treat -32800 as expected control flow on the client: discard the pending promise and issue the fresh request.","Debounce client-side requests (especially completions/hover) so fewer are issued and canceled.","Ensure the client only cancels request ids that are genuinely still outstanding.","If cancellations are unexpected, audit editor plugins that might send stray $/cancelRequest notifications."],"exampleFix":"// before\nconst res = await sendRequest('textDocument/completion', params); // throws on cancel\n// after\ntry {\n  const res = await sendRequest('textDocument/completion', params);\n} catch (e) {\n  if (e.code === -32800) return; // superseded by a newer request\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isRequestCanceled(e) { return e?.code === -32800 || /Request canceled/.test(e?.message ?? ''); }","tryCatchPattern":"try {\n  return await request(method, params, { requestId });\n} catch (e) {\n  if (isRequestCanceled(e)) return undefined; // superseded; ignore\n  throw e;\n}","preventionTips":["Debounce completion/hover requests during rapid typing","Only cancel request ids that are actually outstanding","Design request pipelines to tolerate dropped (canceled) responses"],"tags":["lsp","cancellation","json-rpc","async"],"backgroundTag":"request-canceled","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"}