julia-vscode / LanguageServer.jl

An implementation of the Microsoft Language Server Protocol for the Julia language.
Other
365 stars 80 forks source link

Warning: Client 1 quit with exit code 1 and signal 0 #1182

Open codemeleon opened 1 year ago

codemeleon commented 1 year ago

Hi ,

I get "Warning: Client 1 quit with exit code 1 and signal 0" and then Auto-completion/LSP stops working. I am using Neovim-0.8 and using default lsp configuration from https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#julials .

Please help to fix this issue.

Thank you

fredrikekre commented 1 year ago

You need to provide something to work with. What did you do when it exited? What is in the log file?

codemeleon commented 1 year ago

It exits at the first auto-completion of the code. Please find attached log file. lsp.log

fredrikekre commented 1 year ago

The error is

ERROR: Unknown method completionItem/resolve.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] dispatch_msg(x::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::JSONRPC.MsgDispatcher, msg::
Dict{String, Any})
   @ JSONRPC ~/.julia/packages/JSONRPC/P0G1p/src/
typed.jl:81
 [3] run(server::LanguageServerInstance)
   @ LanguageServer ~/.julia/packages/LanguageServer/0vsx2/src/languageserverinstance.jl:382
 [4] top-level scope
   @ none:31
codemeleon commented 1 year ago

@fredrikekre How can I fix the issue? Any recommendation?

fredrikekre commented 1 year ago

What is your completion setup? LanguageServer.jl does not provide this method, and the client should therefore not request it, see https://github.com/julia-vscode/LanguageServer.jl/blob/1af37e28315872c21654a67c0805f547d81cf51f/src/requests/init.jl#L12 and https://github.com/julia-vscode/LanguageServer.jl/blob/1af37e28315872c21654a67c0805f547d81cf51f/src/protocol/completion.jl#L64-L65

jwortmann commented 1 year ago

I think the underlying problem was already extensively discussed in #1155 - without any real solution.

Now with this example from Neovim there is apparently another client which doesn't check server capabilities. Yes, ultimately it is the client to blame here, but there would be an absolutely trivial solution to this problem, preventing future issue reports of this kind, vastly improving user experience by not crashing anymore, and requiring only a single line change in JSONRPC.jl:

diff --git a/src/typed.jl b/src/typed.jl
index 34cfe3b..5335dba 100644
--- a/src/typed.jl
+++ b/src/typed.jl
@@ -78,7 +78,7 @@ function dispatch_msg(x::JSONRPCEndpoint, dispatcher::MsgDispatcher, msg)
                 end
             end
         else
-            error("Unknown method $method_name.")
+            send_error_response(x, msg, -32601, "Unknown method $method_name.", nothing)
         end
     finally
         dispatcher._currentlyHandlingMsg = false

:upside_down_face:

Edit: Actually still need to add a check in the suggested change above, whether the original message has an id, to only send the error response on unknown requests and not on notifications.

fredrikekre commented 1 year ago

Neovim is very strict in checking capabilities and I have never seen this error before (or any other error where neovim sends unsupported requests, most likely this is something specific to the completion setup by @codemeleon .