diff --git a/lib/capybara/apparition/driver/chrome_client.rb b/lib/capybara/apparition/driver/chrome_client.rb index 6854640..c599b2a 100644 --- a/lib/capybara/apparition/driver/chrome_client.rb +++ b/lib/capybara/apparition/driver/chrome_client.rb @@ -51,6 +51,7 @@ def initialize(ws_url) def stop @ws.close + @events.push(nil) end def on(event_name, session_id = nil, &block) @@ -159,6 +160,7 @@ def read_msg def cleanup_async_responses loop do + break if [:closing, :closed].include?(@ws.driver.state) @msg_mutex.synchronize do @message_available.wait(@msg_mutex, 0.1) (@responses.keys & @async_ids).each do |msg_id| @@ -173,6 +175,7 @@ def cleanup_async_responses def process_messages # run handlers in own thread so as not to hang message processing loop do + break if [:closing, :closed].include?(@ws.driver.state) event = @events.pop next unless event