diff options
| author | Matěj Cepl <mcepl@cepl.eu> | 2026-10-01 11:49:23 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-10-02 08:10:45 +0200 |
| commit | a518f066f320075daca2fb9dbeb7d8607063ee23 (patch) | |
| tree | 6fb5af41694b783f81ebcf3097ae74d67a89b108 | |
| parent | c5d260a3b65cff246fbc8e3828e1f4a0c16304ba (diff) | |
| download | vis-lspc-a518f066f320075daca2fb9dbeb7d8607063ee23.tar.gz vis-lspc-a518f066f320075daca2fb9dbeb7d8607063ee23.zip | |
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.
| -rw-r--r-- | init.lua | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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 |
