Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

### Compatible changes

* `chromedriver-update` command: handles offline and DNS resolution errors.

### Breaking changes


Expand Down
18 changes: 9 additions & 9 deletions lib/geordi/chromedriver_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def fetch_response(url, error_message)

# Rescue Errno::NOERROR, Errno::ENOENT, Errno::EACCES, Errno::EFAULT, Errno::ECONNREFUSED, Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EHOSTDOWN, Errno::EHOSTUNREACH, ...,
# all of which are a subclass of SystemCallError
rescue SystemCallError => e
# and DNS / resolution errors (SocketError, including Socket::ResolutionError on 3.3+)
rescue SystemCallError, SocketError => e
raise ProcessingError, "Request failed: #{e.message}"
end

Expand All @@ -110,15 +111,14 @@ def chromedriver_url(chrome_version)
end

def chromedriver_download_data
return @chromedriver_download_data if @chromedriver_download_data

fetch_response(VERSIONS_PER_MILESTONES_URL, "Could not find chromedriver download data") do |response|
begin
chromedriver_download_data = JSON.parse(response.body)
rescue JSON::ParserError
raise ProcessingError, "Could not parse chromedriver download data."
@chromedriver_download_data ||= begin
fetch_response(VERSIONS_PER_MILESTONES_URL, "Could not find chromedriver download data") do |response|
begin
JSON.parse(response.body)
rescue JSON::ParserError
raise ProcessingError, "Could not parse chromedriver download data."
end
end
@chromedriver_download_data = chromedriver_download_data
end
end

Expand Down
7 changes: 7 additions & 0 deletions spec/chromedriver_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

subject.run(exit_on_failure: false)
end

it 'handles offline errors' do
allow(Net::HTTP).to receive(:get_response).and_raise(SocketError, 'Failed to open TCP connection to googlechromelabs.github.io:443 (getaddrinfo: Temporary failure in name resolution)')
expect(Geordi::Interaction).to receive(:warn).with('Request failed: Failed to open TCP connection to googlechromelabs.github.io:443 (getaddrinfo: Temporary failure in name resolution)')

subject.run(exit_on_failure: false)
end
end
end
end