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 #10574

Closed
dokisha opened this issue Apr 24, 2022 · 4 comments 路 Fixed by #10577
Closed

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

dokisha opened this issue Apr 24, 2022 · 4 comments 路 Fixed by #10577
Labels
C-devtools BiDi or Chrome DevTools related issues C-rb I-defect

Comments

@dokisha
Copy link

dokisha commented Apr 24, 2022

What happened?

Intercepting network response crashes the browser.

@titusfortner said:
the code is assuming responseHeaders will be there, but that's optional according to chromedevtools.github.io/devtools-protocol/tot/Fetch

How can we reproduce the issue?

#issue is reproduced by typing `irb` and pasting the code below

require "watir"
require "selenium/devtools"

Selenium::WebDriver::Chrome::Service.driver_path = '/chromedriver99.0.4844.51'
Selenium::WebDriver::Chrome.path = '/chrome99.0.4844.84/google-chrome'
options = Selenium::WebDriver::Chrome::Options.new
options.add_option("args", ["--no-sandbox"])

browser = Watir::Browser.new :chrome, options: options

log_file = File.open("/tmp/network.log", '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

browser.goto "youtube.com" #this crashes the browser

Relevant log output

#<Thread:0x00005590f1bcda90@/selenium-webdriver-4.1.0/lib/selenium/webdriver/devtools.rb:145 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
        3: from /selenium-webdriver-4.1.0/lib/selenium/webdriver/devtools.rb:155:in `block in callback_thread'
        2: from /selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb:68:in `block in intercept'
        1: from /selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb:109:in `intercept_response'
/selenium-webdriver-4.1.0/lib/selenium/webdriver/devtools/response.rb:38:in `from': undefined method `each_with_object' for nil:NilClass (NoMethodError)

Operating System

Ubuntu

Selenium version

ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]

What are the browser(s) and version(s) where you see this issue?

Chrome 99.0.4844.84

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver99.0.4844.51

Are you using Selenium Grid?

No

@github-actions
Copy link

@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!

@titusfortner titusfortner added C-rb C-devtools BiDi or Chrome DevTools related issues and removed needs-triaging labels Apr 24, 2022
@meetme2meat
Copy link
Contributor

meetme2meat commented Apr 26, 2022

@titusfortner I'm facing the similar. If it works for you we can safeguard that (using a PR). replacing this

https://github.com/SeleniumHQ/selenium/blob/trunk/rb/lib/selenium/webdriver/devtools/response.rb#L38

params.fetch('responseHeaders', []).each_with_ob...

@titusfortner
Copy link
Member

PRs very appreciated, ideally with a spec. Do we know when the response header won't be present?

meetme2meat pushed a commit to meetme2meat/selenium-1 that referenced this issue Apr 26, 2022
titusfortner pushed a commit that referenced this issue May 9, 2022
* fixes #10574

Co-authored-by: Virendra Negi <virendra.negi@sugarboxnetworks.com>
@github-actions
Copy link

github-actions bot commented Jun 9, 2022

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 Jun 9, 2022
elgatov pushed a commit to elgatov/selenium that referenced this issue Jun 27, 2022
* fixes SeleniumHQ#10574

Co-authored-by: Virendra Negi <virendra.negi@sugarboxnetworks.com>
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

Successfully merging a pull request may close this issue.

3 participants