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

Show server crashed dialog on unexpected output in server's stdout #2296

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

rchl
Copy link
Member

@rchl rchl commented Jul 5, 2023

On int(headers.get("Content-Length")) crashing in JsonRpcProcessor.read_data, we've assumed that it's an expected case happening on server exit. As far as I've observed, the typical data we get on process exit is a newline, but it can also be any other random output that doesn't conform to the HTTP header format.

In either of those cases we were just silently closing the transport, treating it as expected session shutdown.

Changed so that we only silently exit transport if the stdout was a single newline. In other cases propagate the output to the UI so that a crash dialog is shown.

I've also changed the JSON decode error case to also propagate the error to the UI instead of silently ignoring payload. I think this makes more sense but we'd have to see how it works out in practice.

Resolves #2295

@rwols rwols merged commit 75bd043 into main Jul 6, 2023
@rwols rwols deleted the fix/handle-stdout-error branch July 6, 2023 05:40
@predrag-codetribe

This comment was marked as resolved.

@predragnikolic
Copy link
Member

I am wondering if we could print unexpected output to the LSP console,(so we will be aware that the server is returning something unexpected)
and keep the server running.

That would fix #1612

@rchl
Copy link
Member Author

rchl commented Jul 9, 2023

Where do you draw the line? Such behavior is essentially not spec-compliant. I don't think we should be fixing or ignoring server issues like that.

Also I would think that that specific eslint issue should be fixable on the server level.

moetelo pushed a commit to moetelo/twiggy that referenced this pull request Mar 20, 2024
LSP clients such as one for Sublime Text handle [anything non-JSON in
language server output compliant as
error](sublimelsp/LSP#2296) which is probably a
good thing since we should expect proper output for language server
client at all times, and any error should crash server.

Twiggy language server uses output to print log information such as
result of using PHP bin command which messes up JSON parser.

This PR remaps console calls to connection calls, similar to how [Sass
language server does
it](https://github.com/wkillerud/some-sass/blob/eab00574065b210605013e3733f6ed971389c082/packages/language-server/src/node-server.ts#L7-L8).

Addresses
#7 (comment)
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.

LSP server initialization does not respond
4 participants