Skip to content

Commit 24f8d2b

Browse files
authored
Merge pull request #116 from Shopify/vs/prevent_more_http_errors
Prevent connection reset or open timeout from raising
2 parents d31c23e + 4d3833c commit 24f8d2b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/ruby_lsp/ruby_lsp_rails/rails_client.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,21 @@ def model(name)
4848
return unless response.code == "200"
4949

5050
JSON.parse(response.body.chomp, symbolize_names: true)
51-
rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL, Net::ReadTimeout, ServerAddressUnknown
51+
rescue Errno::ECONNREFUSED,
52+
Errno::EADDRNOTAVAIL,
53+
Errno::ECONNRESET,
54+
Net::ReadTimeout,
55+
Net::OpenTimeout,
56+
ServerAddressUnknown
5257
nil
5358
end
5459

5560
sig { void }
5661
def check_if_server_is_running!
5762
request("activate", 0.2)
58-
rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL, ServerAddressUnknown
63+
rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL, Errno::ECONNRESET, ServerAddressUnknown
5964
warn(SERVER_NOT_RUNNING_MESSAGE)
60-
rescue Net::ReadTimeout
65+
rescue Net::ReadTimeout, Net::OpenTimeout
6166
# If the server is running, but the initial request is taking too long, we don't want to block the
6267
# initialization of the Ruby LSP
6368
end

0 commit comments

Comments
 (0)