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

tower-lsp hangs on exit notification #12

Open
mrnossiom opened this issue Nov 12, 2024 · 1 comment
Open

tower-lsp hangs on exit notification #12

mrnossiom opened this issue Nov 12, 2024 · 1 comment

Comments

@mrnossiom
Copy link
Member

mrnossiom commented Nov 12, 2024

Many users of tower-lsp have reported issues when sending an exit notification

See original issues ebkalderon/tower-lsp#428, ebkalderon/tower-lsp#399, ebkalderon/tower-lsp#424 (duplicate).
See denoland/deno#20700. Fixed with a timeout workaround on their side.
See Automattic/harper#139.

jfly had already made a PR ebkalderon/tower-lsp#428.

However, I am unsure of the steps taken in his PR. Besides, it changes public API.

Furthermore, after reviewing the relevant part (https://github.com/tower-lsp/tower-lsp/blob/main/src/transport.rs#L134) changing the return to a break should disconnect the channels and stop the join. I couldn't reproduce it with helix tonight. If someone has a minimum repro or steps to see the bug... 😄

EDIT: swapped return and break

@jfly
Copy link

jfly commented Nov 22, 2024

However, I am unsure of the steps taken in his PR

@mrnossiom, I've reposted my PR to this fork, let's discuss over there: #14

Besides, it changes public API.

Are you referring to this? Let's discuss over there.

Furthermore, after reviewing the relevant part (https://github.com/tower-lsp/tower-lsp/blob/main/src/transport.rs#L134) changing the break to a return should disconnect the channels and stop the join

You've linked to a line of code that is a return. Did you mean to say "changing the return to a break"?

If someone has a minimum repro or steps to see the bug... 😄

Sure, here's a minimal repro. You'll need to open 2 terminals.

In terminal 1, clone and run harper-ls:

$ [email protected]:elijah-potter/harper.git
$ cd harper
$ cargo run --bin harper-ls
...
Listening on 127.0.0.1:4000

In terminal 2, run something like this:

$ echo 'print(f"do not panic")  # this is the bst' > /tmp/test.py
$ nix run github:jfly/lsp-client.py -- 127.0.0.1:4000 --open /tmp/test.py -vvv

(If you do not have nix installed, you'll have to clone https://github.com/jfly/lsp-client.py and futz with poetry to run this.)

In terminal 1, you will see harper print this, but it does not exit:

2024-11-22T08:55:53.085179Z  INFO tower_lsp::service::layers: shutdown request received, shutting down
2024-11-22T08:55:53.093449Z  INFO tower_lsp::service::layers: exit notification received, stopping

In terminal 2, you will see something like this:

INFO:lsp_client.client:>> {"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"capabilities": {"textDocument": {"publishDiagnostics": {"dataSupport": true, "relatedInformation": true}}}}}
INFO:lsp_client.client:<< {"jsonrpc":"2.0","result":{"capabilities":{"codeActionProvider":true,"executeCommandProvider":{"commands":["HarperAddToUserDict","HarperAddToFileDict","HarperOpen"]},"textDocumentSync":{"change":1,"openClose":true,"save":true}}},"id":1}
INFO:lsp_client.client:>> {"jsonrpc": "2.0", "method": "initialized", "params": {}}
INFO:lsp_client.client:>> {"jsonrpc": "2.0", "method": "textDocument/didOpen", "params": {"textDocument": {"languageId": "python", "text": "print(f\"do not panic\")  # this is the bst\n", "uri": "file:///tmp/test.py", "version": 0}}}
INFO:lsp_client.client:<< {"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Server initialized!","type":3}}
INFO:lsp_client.client:<< {"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{}]},"id":0}
INFO:lsp_client.client:>> {"jsonrpc": "2.0", "id": 0, "result": []}
INFO:lsp_client.client:<< {"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{}]},"id":1}
INFO:lsp_client.client:>> {"jsonrpc": "2.0", "id": 1, "result": []}
INFO:lsp_client.client:<< {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"This sentence does not start with a capital letter","range":{"end":{"character":27,"line":0},"start":{"character":26,"line":0}},"severity":4,"source":"Harper"},{"message":"Did you mean to spell “bst” this way?","range":{"end":{"character":41,"line":0},"start":{"character":38,"line":0}},"severity":4,"source":"Harper"}],"uri":"file:///tmp/test.py"}}
INFO:lsp_client.client:>> {"jsonrpc": "2.0", "id": 2, "method": "shutdown"}
INFO:lsp_client.client:<< {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///tmp/test.py"}}
INFO:lsp_client.client:<< {"jsonrpc":"2.0","result":null,"id":2}
INFO:lsp_client.client:>> {"jsonrpc": "2.0", "method": "exit"}

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

No branches or pull requests

2 participants