What happened?
Intercepting network response crashes the browser.
Method attach_socket_listener in websocket_connection.rb has Thread.current.abort_on_exception = true which exits the process and crashes the browser.
Producing many requests/responses or repeated requests produce the exception.
How can we reproduce the issue?
# watir (7.1.0)
# selenium-devtools (0.102.0)
# selenium-webdriver (4.3.0)
require 'watir'
require "selenium/devtools"
Selenium::WebDriver::Chrome::Service.driver_path = '/chromedriver100.0.4896.60'
Selenium::WebDriver::Chrome.path = '/chrome100.0.4896.127/google-chrome'
options = Selenium::WebDriver::Chrome::Options.new
options.add_option("args", ["--no-sandbox"])
browser = Watir::Browser.new :chrome, options: options
log_name = "/tmp/network.log"
log_file = File.open(log_name, 'w')
browser.wd.intercept do |request, &continue|
continue.call(request) do |response|
log_file << "#{request.id} \t
#{request.method} \t
#{response.code} \t
#{request.url} \n"
end
end
10.times do browser.goto "youtube.com" end
Relevant log output
Traceback (most recent call last):
6: from /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/websocket_connection.rb:117:in `block in callback_thread'
5: from /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb:68:in `block in intercept'
4: from /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb:114:in `intercept_response'
3: from /usr/local/bundle/gems/selenium-devtools-0.102.0/lib/selenium/devtools/v100/fetch.rb:66:in `continue_request'
2: from /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/devtools.rb:47:in `send_cmd'
1: from /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/websocket_connection.rb:56:in `send_cmd'
/usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/websocket_connection.rb:56:in `write': Broken pipe (Errno::EPIPE)
#<Thread:0x0000560db4b8d4a0 /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/websocket_connection.rb:107 run> terminated with exception (report_on_exception is true):
Another log
Message: -32602: Invalid InterceptionId.:
Class: Selenium::WebDriver::Error::WebDriverError
Backtrace:
[
[0] "/usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/devtools.rb:48:in `send_cmd'",
[1] "/usr/local/bundle/gems/selenium-devtools-0.102.0/lib/selenium/devtools/v100/fetch.rb:66:in `continue_request'",
[2] "/usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb:114:in `intercept_response'",
[3] "/usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb:68:in `block in intercept'",
[4] "/usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/websocket_connection.rb:117:in `block in callback_thread'"
]
Operating System
Ubuntu
Selenium version
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-linux]
What are the browser(s) and version(s) where you see this issue?
Chrome 100.0.4896.127
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 100.0.4896.60
Are you using Selenium Grid?
No
What happened?
Intercepting network response crashes the browser.
Method
attach_socket_listenerin websocket_connection.rb hasThread.current.abort_on_exception = truewhich exits the process and crashes the browser.Producing many requests/responses or repeated requests produce the exception.
How can we reproduce the issue?
Relevant log output
Traceback (most recent call last): 6: from /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/websocket_connection.rb:117:in `block in callback_thread' 5: from /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb:68:in `block in intercept' 4: from /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb:114:in `intercept_response' 3: from /usr/local/bundle/gems/selenium-devtools-0.102.0/lib/selenium/devtools/v100/fetch.rb:66:in `continue_request' 2: from /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/devtools.rb:47:in `send_cmd' 1: from /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/websocket_connection.rb:56:in `send_cmd' /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/websocket_connection.rb:56:in `write': Broken pipe (Errno::EPIPE) #<Thread:0x0000560db4b8d4a0 /usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/websocket_connection.rb:107 run> terminated with exception (report_on_exception is true): Another log Message: -32602: Invalid InterceptionId.: Class: Selenium::WebDriver::Error::WebDriverError Backtrace: [ [0] "/usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/devtools.rb:48:in `send_cmd'", [1] "/usr/local/bundle/gems/selenium-devtools-0.102.0/lib/selenium/devtools/v100/fetch.rb:66:in `continue_request'", [2] "/usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb:114:in `intercept_response'", [3] "/usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb:68:in `block in intercept'", [4] "/usr/local/bundle/gems/selenium-webdriver-4.3.0/lib/selenium/webdriver/common/websocket_connection.rb:117:in `block in callback_thread'" ]Operating System
Ubuntu
Selenium version
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-linux]
What are the browser(s) and version(s) where you see this issue?
Chrome 100.0.4896.127
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 100.0.4896.60
Are you using Selenium Grid?
No