Skip to content

Rescue IOError during shutdown #414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/ruby_lsp/ruby_lsp_rails/runner_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ def initialize
if @wait_thread.alive?
$stderr.puts("Ruby LSP Rails is force killing the server")
sleep(0.5) # give the server a bit of time if we already issued a shutdown notification

# Windows does not support the `TERM` signal, so we're forced to use `KILL` here
Process.kill(T.must(Signal.list["KILL"]), @wait_thread.pid)
force_kill
end
end
end
Expand Down Expand Up @@ -149,6 +147,9 @@ def shutdown
send_message("shutdown")
sleep(0.5) # give the server a bit of time to shutdown
[@stdin, @stdout, @stderr].each(&:close)
rescue IOError
# The server connection may have died
force_kill
end

sig { returns(T::Boolean) }
Expand Down Expand Up @@ -203,6 +204,12 @@ def read_response
# The server connection died
nil
end

sig { void }
def force_kill
# Windows does not support the `TERM` signal, so we're forced to use `KILL` here
Process.kill(T.must(Signal.list["KILL"]), @wait_thread.pid)
end
end

class NullClient < RunnerClient
Expand Down
Loading