BoundaryML/baml · info · LspError

-32800

-32800

Error message

Request canceled: {0}

What it means

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.

Source

Thrown at baml_language/crates/baml_lsp/src/error.rs:42

    /// Bounded transport backpressure (LSP `RequestFailed`, `-32803`).
    #[error("LSP outbound sink is saturated")]
    OutboundSaturated,
    /// A frame larger than the transport limit (LSP `RequestFailed`,
    /// `-32803`).
    #[error("LSP outbound frame exceeds the transport limit")]
    OutboundOversized,
    #[error("Invalid command arguments for command: {command}: {message}")]
    InvalidCommandArguments { command: String, message: String },
    #[error("File not found: {}", .0.display())]
    FileNotFound(PathBuf),
    #[error("Path is invalid: {}: {message}", path.display())]
    InvalidPath { path: PathBuf, message: String },
    /// The document's path is under no known source root.
    #[error("No source root contains {}", .0.display())]
    NoRootForPath(PathBuf),
    /// Cancellation claimed the response while the request was queued or
    /// running (LSP `RequestCanceled`, `-32800`).
    #[error("Request canceled: {0}")]
    RequestCanceled(String),
    /// The request's snapshot became stale under an applied source change
    /// (LSP `ContentModified`, `-32801`).
    #[error("Content modified: {0}")]
    ContentModified(String),
    /// A valid request that cannot be served right now (LSP `RequestFailed`,
    /// `-32803`).
    #[error("{0}")]
    RequestFailed(String),
    /// Violated invariants, panics, serialization (LSP `InternalError`,
    /// `-32603`).
    #[error("Internal error: {0}")]
    Internal(String),
    /// Malformed params, position, or range (LSP `InvalidParams`, `-32602`).
    #[error("Invalid params: {0}")]
    InvalidParams(String),
    /// A request before `initialize` completed (LSP `ServerNotInitialized`,
    /// `-32002`).

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Treat -32800 as expected control flow on the client: discard the pending promise and issue the fresh request.
  2. Debounce client-side requests (especially completions/hover) so fewer are issued and canceled.
  3. Ensure the client only cancels request ids that are genuinely still outstanding.
  4. If cancellations are unexpected, audit editor plugins that might send stray $/cancelRequest notifications.

Example fix

// before
const res = await sendRequest('textDocument/completion', params); // throws on cancel
// after
try {
  const res = await sendRequest('textDocument/completion', params);
} catch (e) {
  if (e.code === -32800) return; // superseded by a newer request
  throw e;
}
Defensive patterns

Strategy: try-catch

Type guard

function isRequestCanceled(e) { return e?.code === -32800 || /Request canceled/.test(e?.message ?? ''); }

Try / catch

try {
  return await request(method, params, { requestId });
} catch (e) {
  if (isRequestCanceled(e)) return undefined; // superseded; ignore
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/b02dd254517f075c. Report an issue: GitHub.