ebkalderon / tower-lsp

Language Server Protocol implementation written in Rust
Apache License 2.0
1k stars 55 forks source link

Handle incoming zero-length messages #271

Closed ebkalderon closed 3 years ago

ebkalderon commented 3 years ago

Fixed

While these messages are peculiar, they seem to be allowed by the LSP spec. The current code fails to parse such messages with the following error:

failed to decode message: unable to parse JSON body: EOF while parsing a value at line 1 column 0

This is ultimately emitted by serde_json::from_str which is unable to deserialize the zero-length string as JSON. To resolve this, we add a special case to the decoder which detects zero-length messages and ignores them, skipping forward to decode the next message in the stream.

Fixes #239.