{"record":{"id":"dbb1b6be7a451811","repo":"BoundaryML/baml","slug":"32803-lsp-outbound-sink-is-saturated","errorCode":"-32803","errorMessage":"LSP outbound sink is saturated","messagePattern":"LSP outbound sink is saturated","errorType":"error_code","errorClass":"LspError","httpStatus":null,"severity":"warning","filePath":"baml_language/crates/baml_lsp/src/error.rs","lineNumber":25,"sourceCode":"/// Serialized to the wire exclusively through [`LspError::to_response_error`];\n/// the legacy `-32001 UnknownErrorCode` is never emitted.\n#[derive(Debug, thiserror::Error)]\npub enum LspError {\n    #[error(\"{0}\")]\n    NotificationExtractError(lsp_server::ExtractError<lsp_server::Notification>),\n    #[error(\"Notification not supported: {0}\")]\n    NotificationNotSupported(String),\n    #[error(\"{0}\")]\n    RequestExtractError(lsp_server::ExtractError<lsp_server::Request>),\n    #[error(\"Request not supported: {0}\")]\n    RequestNotSupported(String),\n    #[error(\"Failed to serialize request result: {0}\")]\n    RequestSerializeError(serde_json::Error),\n    /// The client's sink is gone; nothing more can be delivered.\n    #[error(\"Client closed\")]\n    ClientClosed,\n    /// 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),","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp/src/error.rs#L7-L43","documentation":"LspError::OutboundSaturated indicates bounded-transport backpressure: the outbound sink's buffer is full, so the server cannot immediately send a message. It maps to LSP RequestFailed error code -32803. Backpressure is a flow-control signal, not data corruption.","triggerScenarios":"Sending responses/notifications faster than the client drains the bounded channel; a burst of diagnostics or a large publishDiagnostics after a batch edit filling the sink capacity.","commonSituations":"Publishing diagnostics for every keystroke on a large project; slow or stalled client (frozen editor UI); misconfigured tiny sink buffer.","solutions":["Retry the send after yielding (the sink may drain shortly); or await capacity asynchronously","Coalesce/dedupe diagnostics so fewer messages are sent","Increase the outbound channel capacity if the transport is legitimately undersized"],"exampleFix":"// before\nsink.send(msg)?; // saturates under diagnostic bursts\n// after (retry with yield)\nfor _ in 0..3 {\n    match sink.try_send(msg.clone()) {\n        Ok(()) => break,\n        Err(LspError::OutboundSaturated) => tokio::time::yield_now().await,\n        Err(e) => return Err(e),\n    }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"fn is_saturated(e: &LspError) -> bool {\n    matches!(e, LspError::OutboundSaturated)\n}","tryCatchPattern":"loop {\n    match sink.try_send(msg.clone()) {\n        Ok(()) => break,\n        Err(LspError::OutboundSaturated) => tokio::time::sleep(Duration::from_millis(10)).await,\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Coalesce diagnostics before publishing instead of sending per keystroke","Use an async send that awaits capacity rather than try_send","Size the outbound channel generously relative to diagnostic burst rate"],"tags":["lsp","backpressure","transport","rust"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}