diff options
author | Mathias Fussenegger <f.mathias@zignar.net> | 2021-06-25 14:45:17 +0200 |
---|---|---|
committer | Mathias Fussenegger <f.mathias@zignar.net> | 2021-06-25 14:45:17 +0200 |
commit | 58473178ff217079e6a0afd8926b262199477538 (patch) | |
tree | 2adf91d11308a7389b74d2cc989ff615e41daacd /runtime/lua/vim/lsp/rpc.lua | |
parent | 510ed996d2a92de527c70888208e3ad7ce157126 (diff) | |
download | rneovim-58473178ff217079e6a0afd8926b262199477538.tar.gz rneovim-58473178ff217079e6a0afd8926b262199477538.tar.bz2 rneovim-58473178ff217079e6a0afd8926b262199477538.zip |
fix(lsp): Handle nil message_callbacks
The `onexit` handler could set `message_callbacks` to `nil` within the
luv event loop while the mainloop runs a function that tries to access
`message_callbacks`.
This adds some checks to prevent errors in that case.
Fixes https://github.com/neovim/neovim/issues/14863
Diffstat (limited to 'runtime/lua/vim/lsp/rpc.lua')
-rw-r--r-- | runtime/lua/vim/lsp/rpc.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index ea12c97d40..4c5f02af9d 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -449,7 +449,7 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params) method = method; params = params; } - if result then + if result and message_callbacks then message_callbacks[message_id] = schedule_wrap(callback) return result, message_id else @@ -548,14 +548,14 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params) -- - The server will not send a result callback after this cancellation. -- - If the server sent this cancellation ACK after sending the result, the user of this RPC -- client will ignore the result themselves. - if result_id then + if result_id and message_callbacks then message_callbacks[result_id] = nil end return end end - local callback = message_callbacks[result_id] + local callback = message_callbacks and message_callbacks[result_id] if callback then message_callbacks[result_id] = nil validate { |