summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/lsp/rpc.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-04-24 07:40:33 -0400
committerGitHub <noreply@github.com>2026-04-24 07:40:33 -0400
commit2c7679f4d380deb05785476e925147bed032a1a9 (patch)
treebbf87b41bb7417c2a15823fb1f72599a69934692 /runtime/lua/vim/lsp/rpc.lua
parent5c88492a13f80d23e7b0d48d036ed60a7d24be0d (diff)
fix(lsp): more info in error msg, deduplicate test #39359
Diffstat (limited to 'runtime/lua/vim/lsp/rpc.lua')
-rw-r--r--runtime/lua/vim/lsp/rpc.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua
index 234f895f2b..7d85be89c9 100644
--- a/runtime/lua/vim/lsp/rpc.lua
+++ b/runtime/lua/vim/lsp/rpc.lua
@@ -454,8 +454,16 @@ function Client:handle_body(body)
-- Received a request.
if type(decoded.method) == 'string' and decoded.id and decoded.id ~= vim.NIL then
- local id_type = type(decoded.id)
- assert(id_type == 'number' or id_type == 'string', 'Request id must be a number or a string')
+ if type(decoded.id) ~= 'number' and type(decoded.id) ~= 'string' then
+ log.error(
+ 'Server request id must be a number or string, got ' .. type(decoded.id),
+ decoded.method,
+ decoded.id
+ )
+ self:on_error(M.client_errors.INVALID_SERVER_MESSAGE, decoded)
+ return
+ end
+
-- Schedule here so that the users functions don't trigger an error and
-- we can still use the result.
vim.schedule(coroutine.wrap(function()
@@ -553,7 +561,7 @@ function Client:handle_body(body)
log.error('No callback found for server response id ' .. result_id)
end
elseif decoded.id == vim.NIL then
- log.warn('Server sent response with null id', decoded.error)
+ log.warn('Server sent response with null id', decoded.method, decoded.error)
self:on_error(M.client_errors.INVALID_SERVER_MESSAGE, decoded)
elseif type(decoded.method) == 'string' then
-- Received a notification.