zed-industries/zed · error
cannot read LSP message headers
Error message
cannot read LSP message headers
What it means
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.
Source
Thrown at crates/lsp/src/input_handler.rs:47
/// Handler for stdout of language server.
pub struct LspStdoutHandler {
pub(super) loop_handle: Task<Result<()>>,
pub(super) incoming_messages: Receiver<NotificationOrRequest>,
}
async fn read_headers<Stdout>(reader: &mut BufReader<Stdout>, buffer: &mut Vec<u8>) -> Result<()>
where
Stdout: AsyncRead + Unpin + Send + 'static,
{
loop {
if buffer.len() >= HEADER_DELIMITER.len()
&& buffer[(buffer.len() - HEADER_DELIMITER.len())..] == HEADER_DELIMITER[..]
{
return Ok(());
}
if reader.read_until(b'\n', buffer).await? == 0 {
anyhow::bail!("cannot read LSP message headers");
}
}
}
impl LspStdoutHandler {
pub fn new<Input>(
stdout: Input,
response_handlers: Arc<Mutex<Option<HashMap<RequestId, ResponseHandler>>>>,
io_handlers: Arc<Mutex<HashMap<i32, IoHandler>>>,
cx: BackgroundExecutor,
) -> Self
where
Input: AsyncRead + Unpin + Send + 'static,
{
let (tx, notifications_channel) = channel(INCOMING_MESSAGE_QUEUE_CAPACITY);
let loop_handle = cx.spawn(Self::handler(stdout, tx, response_handlers, io_handlers));
Self {
loop_handle,View on GitHub (pinned to f4178619ac)
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
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/lsp/src/input_handler.rs:47 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/ceda830d14fe7e49.
Report an issue: GitHub.