BoundaryML/baml · info · LspError
-32801
-32801
Error message
Content modified: {0} What it means
LspError::ContentModified indicates the request's snapshot of a document became stale because an edit was applied while the request was queued or executing. It maps to the LSP ContentModified code -32801. This lets the client know the result would not reflect the current document state and should be re-issued against the newer version.
Source
Thrown at baml_language/crates/baml_lsp/src/error.rs:46
/// `-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`).
#[error("Server not initialized: {0}")]
ServerNotInitialized(String),
}
View on GitHub (pinned to bd85ce9dee)
Solutions
- Client should catch code -32801 and simply re-send the request with the current document version.
- Sequence requests so that a didChange invalidates/supersedes previously issued analysis requests.
- Avoid editing the document programmatically while awaiting dependent requests (formatters, code actions).
- Enable request debouncing/throttling in the client to reduce races with edits.
Example fix
// before
const edits = await request('textDocument/formatting', params);
// after
async function format(params) {
try {
return await request('textDocument/formatting', params);
} catch (e) {
if (e.code === -32801) return format(params); // retry on stale snapshot
throw e;
}
} Defensive patterns
Strategy: retry
Type guard
function isContentModified(e) { return e?.code === -32801 || /Content modified/.test(e?.message ?? ''); } Try / catch
async function withStaleRetry(fn, retries = 2) {
try { return await fn(); }
catch (e) {
if (isContentModified(e) && retries > 0) return withStaleRetry(fn, retries - 1);
throw e;
}
} Prevention
- Version-gate requests: attach and check the document version
- Suppress editing during awaited format/code-action requests
- Debounce didChange-driven request storms
When it happens
Trigger: A didChange notification arrives between when a request (completion, code action, formatting) was received and when its result is computed; the document version the request was based on no longer matches the server's current version.
Common situations: Fast typing during completion/compute-diagnostics; auto-save or format-on-save racing an in-flight request; batch tooling editing files while analysis requests are pending.
Related errors
- Only one change event, with full text, is supported for unsa
- {0}
- Notification not supported: {0}
- Request not supported: {0}
- Failed to serialize request result: {0}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/910427680900eb94.
Report an issue: GitHub.