mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
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
This commit is contained in:
@@ -449,7 +449,7 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params)
|
|||||||
method = method;
|
method = method;
|
||||||
params = params;
|
params = params;
|
||||||
}
|
}
|
||||||
if result then
|
if result and message_callbacks then
|
||||||
message_callbacks[message_id] = schedule_wrap(callback)
|
message_callbacks[message_id] = schedule_wrap(callback)
|
||||||
return result, message_id
|
return result, message_id
|
||||||
else
|
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.
|
-- - 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
|
-- - If the server sent this cancellation ACK after sending the result, the user of this RPC
|
||||||
-- client will ignore the result themselves.
|
-- client will ignore the result themselves.
|
||||||
if result_id then
|
if result_id and message_callbacks then
|
||||||
message_callbacks[result_id] = nil
|
message_callbacks[result_id] = nil
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local callback = message_callbacks[result_id]
|
local callback = message_callbacks and message_callbacks[result_id]
|
||||||
if callback then
|
if callback then
|
||||||
message_callbacks[result_id] = nil
|
message_callbacks[result_id] = nil
|
||||||
validate {
|
validate {
|
||||||
|
|||||||
Reference in New Issue
Block a user