Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃悰 Bug]: Intercepting network response produces exception #10856

Closed
dokisha opened this issue Jul 7, 2022 · 4 comments
Closed

[馃悰 Bug]: Intercepting network response produces exception #10856

dokisha opened this issue Jul 7, 2022 · 4 comments
Labels
C-devtools BiDi or Chrome DevTools related issues C-rb I-defect

Comments

@dokisha
Copy link

dokisha commented Jul 7, 2022

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

@github-actions
Copy link

github-actions bot commented Jul 7, 2022

@dokisha, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol diemol added C-rb and removed needs-triaging labels Jul 8, 2022
@titusfortner
Copy link
Member

This can be reproduced with:

    driver = Selenium::WebDriver.for :chrome

    ids = []
    driver.intercept do |request, &continue|
      continue.call(request) { ids << request.id }
    end

    10.times { driver.get "https://youtube.com" }

@p0deje I want to say this is a Chrome bug somehow? It looks like it happens when the interception-job number is a duplicate of a previous one. Not sure how that happens though. Any ideas?

@titusfortner titusfortner added the C-devtools BiDi or Chrome DevTools related issues label Jul 11, 2022
@p0deje
Copy link
Member

p0deje commented Jul 13, 2022

This happens because the request is aborted (canceled) by the browser on new navigation and after that, we try to continue the already canceled request/response. I'm trying to implement a logic that will track the canceled requests and prevent continuing them.

@p0deje p0deje closed this as completed in 0916b2c Jul 13, 2022
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-devtools BiDi or Chrome DevTools related issues C-rb I-defect
Projects
None yet
Development

No branches or pull requests

4 participants