{"record":{"id":"ceda830d14fe7e49","repo":"zed-industries/zed","slug":"cannot-read-lsp-message-headers","errorCode":null,"errorMessage":"cannot read LSP message headers","messagePattern":"cannot read LSP message headers","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/lsp/src/input_handler.rs","lineNumber":47,"sourceCode":"/// Handler for stdout of language server.\npub struct LspStdoutHandler {\n    pub(super) loop_handle: Task<Result<()>>,\n    pub(super) incoming_messages: Receiver<NotificationOrRequest>,\n}\n\nasync fn read_headers<Stdout>(reader: &mut BufReader<Stdout>, buffer: &mut Vec<u8>) -> Result<()>\nwhere\n    Stdout: AsyncRead + Unpin + Send + 'static,\n{\n    loop {\n        if buffer.len() >= HEADER_DELIMITER.len()\n            && buffer[(buffer.len() - HEADER_DELIMITER.len())..] == HEADER_DELIMITER[..]\n        {\n            return Ok(());\n        }\n\n        if reader.read_until(b'\\n', buffer).await? == 0 {\n            anyhow::bail!(\"cannot read LSP message headers\");\n        }\n    }\n}\n\nimpl LspStdoutHandler {\n    pub fn new<Input>(\n        stdout: Input,\n        response_handlers: Arc<Mutex<Option<HashMap<RequestId, ResponseHandler>>>>,\n        io_handlers: Arc<Mutex<HashMap<i32, IoHandler>>>,\n        cx: BackgroundExecutor,\n    ) -> Self\n    where\n        Input: AsyncRead + Unpin + Send + 'static,\n    {\n        let (tx, notifications_channel) = channel(INCOMING_MESSAGE_QUEUE_CAPACITY);\n        let loop_handle = cx.spawn(Self::handler(stdout, tx, response_handlers, io_handlers));\n        Self {\n            loop_handle,","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/lsp/src/input_handler.rs#L29-L65","documentation":"Raised when read_headers hits EOF on the language server's stdout before a complete LSP Content-Length header block was received: the server exited or closed its output without sending a message. Not a header syntax error — the stream ended prematurely.","triggerScenarios":"Thrown at crates/lsp/src/input_handler.rs:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the language server logs for a crash or startup failure","Verify the server binary is compatible with the platform and not missing libraries","Restart the language server / Zed and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}