Skip to content

Prevent connection reset or open timeout from raising #116

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
Aug 1, 2023
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
11 changes: 8 additions & 3 deletions lib/ruby_lsp/ruby_lsp_rails/rails_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,21 @@ def model(name)
return unless response.code == "200"

JSON.parse(response.body.chomp, symbolize_names: true)
rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL, Net::ReadTimeout, ServerAddressUnknown
rescue Errno::ECONNREFUSED,
Errno::EADDRNOTAVAIL,
Errno::ECONNRESET,
Net::ReadTimeout,
Net::OpenTimeout,
ServerAddressUnknown
nil
end

sig { void }
def check_if_server_is_running!
request("activate", 0.2)
rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL, ServerAddressUnknown
rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL, Errno::ECONNRESET, ServerAddressUnknown
warn(SERVER_NOT_RUNNING_MESSAGE)
rescue Net::ReadTimeout
rescue Net::ReadTimeout, Net::OpenTimeout
# If the server is running, but the initial request is taking too long, we don't want to block the
# initialization of the Ruby LSP
end
Expand Down