JakeBecker / elixir-ls

A frontend-independent IDE "smartness" server for Elixir. Implements the JSON-based "Language Server Protocol" standard and provides debugger support via VS Code's debugger protocol.
Apache License 2.0
846 stars 52 forks source link

requestMessage doesn't seem to match spec for 2 arity variant #209

Closed bfolkens closed 4 years ago

bfolkens commented 4 years ago

Description

When exiting Neovim using vim-lsc, message "[lsc:Error] ElixirLS has crashed. See Output panel." is shown. Upon investigation, ElixirLS is throwing an exception (below).

I had originally opened this as #207, with the conclusion that it was the shutdown method being called out of order. However, after further investigation I noticed the requestMessage protocol definition may not be to spec. In the specification, the params is optional. However, in the code it seems to only expect the 3 arity variant: %{"id" => _, "method" => _, "params" => _, "jsonrpc" => "2.0"}.

Possibly related: #189

Steps to Reproduce

  1. Open an Elixir file in a (Neo)vim instance using vim-lsc.
  2. Ensure the ElixirLS is running.
  3. Close the file.

Expected Behavior

The language server should exit cleanly.

Actual Behavior

ElixirLS crashes with the following:

21:16:59.997 [error] GenServer ElixirLS.LanguageServer.Server terminating
** (FunctionClauseError) no function clause matching in ElixirLS.LanguageServer.Server.handle_notification/2
    (language_server) lib/language_server/server.ex:216: ElixirLS.LanguageServer.Server.handle_notification(%{"id" => 2, "jsonrpc" => "2.0", "method" => "shutdown"}, %ElixirLS.LanguageServer.Server{analysis_ready?: false, awaiting_contracts: [], build_diagnostics: [], build_ref: nil, build_running?: false, client_capabilities: %{"textDocument" => %{"codeAction" => %{"codeActionLiteralSupport" => %{"codeActionKind" => %{"valueSet" => ["quickfix", "refactor", "source"]}}}, "completion" => %{"completionItem" => %{"snippetSupport" => false}}, "definition" => %{"dynamicRegistration" => false}, "signatureHelp" => %{"dynamicRegistration" => false}, "synchronization" => %{"didSave" => false, "willSave" => false, "willSaveWaitUntil" => false}}, "workspace" => %{"applyEdit" => true}}, dialyzer_diagnostics: [], dialyzer_sup: nil, needs_build?: false, project_dir: nil, received_shutdown?: false, requests: %{}, root_uri: "file:///Users/[redacted]/[project]" settings: nil, source_files: %{}})
    (language_server) lib/language_server/server.ex:144: ElixirLS.LanguageServer.Server.handle_cast/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:"$gen_cast", {:receive_packet, %{"id" => 2, "jsonrpc" => "2.0", "method" => "shutdown"}}}
State: %ElixirLS.LanguageServer.Server{analysis_ready?: false, awaiting_contracts: [], build_diagnostics: [], build_ref: nil, build_running?: false, client_capabilities: %{"textDocument" => %{"codeAction" => %{"codeActionLiteralSupport" => %{"codeActionKind" => %{"valueSet" => ["quickfix", "refactor", "source"]}}}, "completion" => %{"completionItem" => %{"snippetSupport" => false}}, "definition" => %{"dynamicRegistration" => false}, "signatureHelp" => %{"dynamicRegistration" => false}, "synchronization" => %{"didSave" => false, "willSave" => false, "willSaveWaitUntil" => false}}, "workspace" => %{"applyEdit" => true}}, dialyzer_diagnostics: [], dialyzer_sup: nil, needs_build?: false, project_dir: nil, received_shutdown?: false, requests: %{}, root_uri: "file:///Users/[redacted]/[project]", settings: nil, source_files: %{}}

Environment

Elixir & Erlang versions (elixir --version):

Erlang/OTP 22 [erts-10.5.6] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.9.4 (compiled with Erlang/OTP 22)

Operating system:

MacOS Catalina - 10.15.3 (19D76)

Client (editor or IDE):

vim-lsc 0.4.0
NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/config -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/src -I/usr/local/include -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/deps-build/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/src/nvim/auto -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/include
Compiled by brew@Catalina.local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.4.3/share/nvim"

Run :checkhealth for more info
JakeBecker commented 4 years ago

This project has moved!

It's now being maintained by proactive volunteers from the Elixir community over at elixir-lsp/elixir-ls. Updates will continue to be published from that repo to the original VS Code extension, so no need to switch plugins if you're using VS Code.

To avoid inundating the new maintainers with issues, please verify that your issue persists with the latest version of the extension (which is published from the new repo) before re-filing your issue there.

Thanks for using ElixirLS!