From b99df2df2ee591d2d6f706a1d0d1dd81c52e26af Mon Sep 17 00:00:00 2001 From: Clayton Smith Date: Thu, 26 Aug 2021 07:52:51 -0400 Subject: [PATCH] Fix resource leaks --- lib/capybara/apparition/driver/chrome_client.rb | 3 +++ 1 file changed, 3 insertions(+) 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