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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

::TimeoutError is deprecated #6122

Closed
ninp0 opened this issue Jul 6, 2018 · 10 comments
Closed

::TimeoutError is deprecated #6122

ninp0 opened this issue Jul 6, 2018 · 10 comments
Labels

Comments

@ninp0
Copy link

ninp0 commented Jul 6, 2018

Meta -

OS:
OSX & Linux

Selenium Version:
selenium-webdriver 3.13.0

Browser:
Firefox

/usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.12.0/lib/selenium/webdriver/common/error.rb:35: warning: constant ::TimeoutError is deprecated

Please change to Timeout::Error to avoid deprecation warnings.

@luke-hill
Copy link
Contributor

Because you're calling a method which is meta-programming in the error. Can you provide a bit more of a stacktrace.

I'll happily fix this up. But need a bit more knowledge to confirm you're triggering this in the way I think.

@lmtierney
Copy link
Member

Apparently TimeoutError was deprecated in ruby 2.3.0 so we just need to update the constant used to Timeout::Error

@barancev barancev added the C-rb label Jul 6, 2018
@ninp0
Copy link
Author

ninp0 commented Jul 7, 2018

@luke-hill - Here's how's it's being used which ultimately triggers the deprecation warning:

https://github.com/ninp0/csi/blob/master/lib/csi/plugins/owasp_zap.rb#L445-L465

Here's how the this_browser_obj in the code above is created:

https://github.com/ninp0/csi/blob/master/lib/csi/plugins/transparent_browser.rb#L35-L73

@luke-hill
Copy link
Contributor

@ninp0 What I was interested in was the 2nd / 3rd lines of the stacktrace. Not the source.

As discussed above, something is generating the string Timeout which then gets converted into our TimeoutError which is deprecated. If you can code snippet the top 5-10 lines that would help

@ninp0
Copy link
Author

ninp0 commented Jul 9, 2018

@luke-hill no stack trace - just a warning (see csi[v0.3.16]:005):

# Open up the csi automation prototyper shell
$ csi
csi[v0.3.16]:001 >>> api_key = '<masked>'

csi[v0.3.16]:002 >>> zap_obj = CSI::Plugins::OwaspZap.start(api_key: api_key)

csi[v0.3.16]:003 >>> browser_obj = CSI::Plugins::TransparentBrowser.open(browser_type: :firefox, proxy: 'http://127.0.0.1:8080')

csi[v0.3.16]:004 >>> CSI::Plugins::OwaspZap.breakpoint(zap_obj: zap_obj, regex_type: :url, regex_pattern: '^https://0dayinc.com/$')
=> <RestClient::Response 200 "{\"Result\":\"...">

csi[v0.3.16]:005 >>> CSI::Plugins::OwaspZap.request(zap_obj: zap_obj, browser_obj: browser_obj, instruction: 'goto("https://0dayinc.com/")')
/usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/common/error.rb:35: warning: constant ::TimeoutError is deprecated
=> "{\"httpMessage\":\"GET https://0dayinc.com/ HTTP/1.1\\r\\nHost: 0dayinc.com\\r\\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0\\r\\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\\r\\nAccept-Language: en-US,en;q=0.5\\r\\nConnection: keep-alive\\r\\nUpgrade-Insecure-Requests: 1\\r\\n\\r\\n\"}"

csi[v0.3.16]:006 >>>

The warning is produced when the CSI::Plugins::OwaspZap.request method is called: https://github.com/ninp0/csi/blob/master/lib/csi/plugins/owasp_zap.rb#L434-L465

which should always return through the Timeout::Error block (ultimately we're making a non-blocking request so we can proceed w/ execution and intercept/tamper with the request in zap...is there an easier way to do a non-blocking request besides rescuing Timeout::Error?):
https://github.com/ninp0/csi/blob/master/lib/csi/plugins/owasp_zap.rb#L449

the rescue in the Timeout::Error block returns a string object:
https://github.com/ninp0/csi/blob/master/lib/csi/plugins/owasp_zap.rb#L462

I notice on the selenium side https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/common/error.rb#L35 is executed when the code variable is a String class. Is this being triggered due to returning a string once Timeout::Error is rescued?

One last thing to note is that watir is being used to instantiate browser_obj (see csi[v0.3.16]:003), which may be the source of this:

https://github.com/watir/watir/blob/fd7820baff3e56d79b06bec1507034d68a9de6e6/lib/watir/wait.rb#L49

I hope that helps!

@luke-hill
Copy link
Contributor

I've never used that plugin and I'm not quite sure looking at the code stack what the heck is happening (It is a bit manic)

Whilst I understand where the error code is being generated it's a bit much to just change that error code as that is a breaking change.

Qu) Are you able to remove those rescues? Because the error being generated by selenium is TimeOutError which is different to ::TimeoutError so I'm not convinced we have the full picture yet.

If we had a stacktrace that showed where that string was coming from it would be a lot easier.

@ninp0
Copy link
Author

ninp0 commented Jul 10, 2018

ok, added a full dump of the stack trace in the rescue:

/usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/common/error.rb:35: warning: constant ::TimeoutError is deprecated
Traceback (most recent call last):
        42: from /usr/local/rvm/gems/ruby-2.5.1@csi/bin/ruby_executable_hooks:15:in `<main>'
        41: from /usr/local/rvm/gems/ruby-2.5.1@csi/bin/ruby_executable_hooks:15:in `eval'
        40: from /usr/local/rvm/gems/ruby-2.5.1@csi/bin/csi:23:in `<main>'
        39: from /usr/local/rvm/gems/ruby-2.5.1@csi/bin/csi:23:in `load'
        38: from /csi/bin/csi:60:in `<top (required)>'
        37: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/pry_class.rb:192:in `start'
        36: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/repl.rb:13:in `start'
        35: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/repl.rb:38:in `start'
        34: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/input_lock.rb:79:in `with_ownership'
        33: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/input_lock.rb:61:in `__with_ownership'
        32: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/repl.rb:38:in `block in start'
        31: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/repl.rb:67:in `repl'
        30: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/repl.rb:67:in `loop'
        29: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/repl.rb:77:in `block in repl'
        28: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/pry_instance.rb:241:in `eval'
        27: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/pry_instance.rb:241:in `catch'
        26: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/pry_instance.rb:242:in `block in eval'
        25: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/pry_instance.rb:242:in `catch'
        24: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/pry_instance.rb:243:in `block (2 levels) in eval'
        23: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/pry_instance.rb:323:in `handle_line'
        22: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/pry_instance.rb:355:in `evaluate_ruby'
        21: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/pry-0.11.3/lib/pry/pry_instance.rb:355:in `eval'
        20: from (pry):6:in `<main>'
        19: from /csi/lib/csi/plugins/owasp_zap.rb:448:in `request'
        18: from /csi/lib/csi/plugins/owasp_zap.rb:448:in `instance_eval'
        17: from (eval):1:in `request'
        16: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/watir-6.10.3/lib/watir/browser.rb:82:in `goto'
        15: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/common/navigation.rb:30:in `to'
        14: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/remote/w3c/bridge.rb:57:in `get'
        13: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/remote/w3c/bridge.rb:535:in `execute'
        12: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/remote/bridge.rb:164:in `execute'
        11: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/remote/http/common.rb:62:in `call'
        10: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/remote/http/default.rb:104:in `request'
         9: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/remote/http/common.rb:84:in `create_response'
         8: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/remote/http/common.rb:84:in `new'
         7: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
         6: from /usr/local/rvm/gems/ruby-2.5.1@csi/gems/selenium-webdriver-3.13.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok'
         5: from get@chrome://marionette/content/listener.js:1050:5
         4: from navigate@chrome://marionette/content/listener.js:411:7
         3: from start@chrome://marionette/content/listener.js:139:7
         2: from notify@chrome://marionette/content/listener.js:341:13
         1: from TimeoutError@chrome://marionette/content/error.js:445:5
/csi/lib/csi/plugins/owasp_zap.rb:448:in `instance_eval': Timeout loading page after 0ms (Timeout::Error)

@twalpole
Copy link
Contributor

twalpole commented Jul 10, 2018

Looks like this was broken in - ee29dab#diff-1828458d7e816f8e53b81cf1952df377 - when the Selenium::WebDriver::Error::TimeoutError class was removed (w3c_error.rb deleted) but was not added as an alias of Selenium::WebDriver::Error::TimeOutError in rb/lib/selenium/webdriver/common/error.rb . Changing Error::for_code - https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/common/error.rb#L35 - to const_get("#{klass_name}Error", false) would have caught this sooner

@twalpole
Copy link
Contributor

twalpole commented Jul 10, 2018

#6137 should fix this

@p0deje
Copy link
Member

p0deje commented Aug 21, 2018

Please try 3.14.0 - it should be fixed there.

@p0deje p0deje closed this as completed Aug 21, 2018
@lock lock bot locked and limited conversation to collaborators Aug 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants