From a518f066f320075daca2fb9dbeb7d8607063ee23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Thu, 1 Oct 2026 11:49:23 +0200 Subject: Handle writes to closed language-server pipes A language server can exit and close its communication pipe before vis-lspc sends its next RPC message. The resulting Lua file-handle error escapes the RPC function and interrupts editing. Catch failures from write and flush, log the server name and error, and return false instead. --- init.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 447b9bb..383d599 100644 --- a/init.lua +++ b/init.lua @@ -668,8 +668,15 @@ function LanguageServer:rpc(req) local msg = header_part .. '\r\n\r\n' .. content_part lspc:log('LSPC Sending -> ' .. self.name .. ': ' .. msg) - self.fd:write(msg) - self.fd:flush() + local ok, err = pcall(function() + self.fd:write(msg) + self.fd:flush() + end) + if not ok then + lspc:warn('Could not send message to ' .. self.name .. ': ' .. tostring(err)) + return false + end + return true end --- Send a RPC notification to the language server -- cgit v1.2.3