Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle incoming zero-length messages #271

Merged
merged 1 commit into from
May 20, 2021
Merged

Conversation

ebkalderon
Copy link
Owner

Fixed

  • Handle incoming messages with a Content-Length of zero.

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.

@ebkalderon ebkalderon self-assigned this May 20, 2021
@ebkalderon ebkalderon force-pushed the handle-zero-length-messages branch 2 times, most recently from e88fd62 to d90e9b4 Compare May 20, 2021 06:56
@ebkalderon ebkalderon changed the title Handle incoming messages with a Content-Length of zero Handle incoming zero-length messages May 20, 2021
@ebkalderon ebkalderon force-pushed the handle-zero-length-messages branch from d90e9b4 to 250ff9b Compare May 20, 2021 08:06
While these messages are peculiar, they seem to be allowed by the 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.
@ebkalderon ebkalderon force-pushed the handle-zero-length-messages branch from 250ff9b to 1f5e598 Compare May 20, 2021 08:06
@ebkalderon ebkalderon merged commit 4e40964 into master May 20, 2021
@ebkalderon ebkalderon deleted the handle-zero-length-messages branch May 20, 2021 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server doesn't exit on receiving exit notification
1 participant