Skip to content

Commit 87253fa

Browse files
committed
Rescue IOError during shutdown
1 parent 83cd510 commit 87253fa

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/ruby_lsp/ruby_lsp_rails/runner_client.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ def initialize
8484
if @wait_thread.alive?
8585
$stderr.puts("Ruby LSP Rails is force killing the server")
8686
sleep(0.5) # give the server a bit of time if we already issued a shutdown notification
87-
88-
# Windows does not support the `TERM` signal, so we're forced to use `KILL` here
89-
Process.kill(T.must(Signal.list["KILL"]), @wait_thread.pid)
87+
force_kill
9088
end
9189
end
9290
end
@@ -149,6 +147,9 @@ def shutdown
149147
send_message("shutdown")
150148
sleep(0.5) # give the server a bit of time to shutdown
151149
[@stdin, @stdout, @stderr].each(&:close)
150+
rescue IOError
151+
# The server connection may have died
152+
force_kill
152153
end
153154

154155
sig { returns(T::Boolean) }
@@ -203,6 +204,12 @@ def read_response
203204
# The server connection died
204205
nil
205206
end
207+
208+
sig { void }
209+
def force_kill
210+
# Windows does not support the `TERM` signal, so we're forced to use `KILL` here
211+
Process.kill(T.must(Signal.list["KILL"]), @wait_thread.pid)
212+
end
206213
end
207214

208215
class NullClient < RunnerClient

0 commit comments

Comments
 (0)