Skip to content

Commit

Permalink
Raise a more specific error if the websocket connection dies
Browse files Browse the repository at this point in the history
  • Loading branch information
yjukaku committed Dec 1, 2021
1 parent ca86be4 commit 1cdda23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/capybara/apparition/driver/chrome_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ def process_messages
puts "Unexpected CDPError: #{e.message}"
end
retry
rescue WebSocketClientError => e
puts "Unexpected websocket connection exception: #{e}: #{e.message}: #{e.backtrace}"
rescue StandardError => e
puts "Unexpected inner loop exception: #{e}: #{e.message}: #{e.backtrace}"
retry
Expand Down
6 changes: 5 additions & 1 deletion lib/capybara/apparition/driver/web_socket_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def start_driver
end

def parse_input
@driver.parse(@socket.read)
data = @socket.read
raise WebSocketClientError.new if data.nil? || data.empty?
data
rescue EOFError, Errno::ECONNRESET
raise WebSocketClientError.new
end
end

Expand Down

0 comments on commit 1cdda23

Please sign in to comment.