Ruby 3.1 Ubuntu gives error on page refresh
Closed this issue · 7 comments
Step To Reproduce / Observed behavior
Start puppeteer window, then reload the page in chrome
Expected behavior
No ruby error
Environment
I just updated to Ruby 3.1, I suspect this is the issue
Paste the output of ruby --version
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux]
W, [2022-01-24T22:46:20.238395 #3184] WARN -- : wrong number of arguments (given 1, expected 0; required keyword: response_received_event) (ArgumentError)
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puppeteer-ruby-0.40.0/lib/puppeteer/network_manager.rb:65:in `initialize'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puppeteer-ruby-0.40.0/lib/puppeteer/network_manager.rb:370:in `new'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puppeteer-ruby-0.40.0/lib/puppeteer/network_manager.rb:370:in `handle_response_received'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puppeteer-ruby-0.40.0/lib/puppeteer/network_manager.rb:102:in `block in initialize'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puppeteer-ruby-0.40.0/lib/puppeteer/event_callbackable.rb:90:in `emit_event'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puppeteer-ruby-0.40.0/lib/puppeteer/cdp_session.rb:59:in `handle_message'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puppeteer-ruby-0.40.0/lib/puppeteer/connection.rb:256:in `handle_message'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puppeteer-ruby-0.40.0/lib/puppeteer/define_async_method.rb:67:in `call'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puppeteer-ruby-0.40.0/lib/puppeteer/define_async_method.rb:67:in `block (2 levels) in define_async_method'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/promises.rb:1582:in `evaluate_to'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/promises.rb:1765:in `block in on_resolvable'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:363:in `run_task'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `block (3 levels) in create_worker'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:335:in `loop'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:335:in `block (2 levels) in create_worker'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `catch'
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.1.9/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block in create_worker'
Another minor problem if you have any ideas - I'm running this from a rails console & ctrl+c is killing the whole process when I run it during a puppeteer wait. Is there any way to rescue this so I can cancel delays early when I realize it's going to fail?
This is fixed in #190, you can try pulling the gem from github
puppeteer-ruby 0.40.1 includes the fix #190. Sorry for late release, and thank you very much for your kind reporting and contributions.
Thanks, that solved it, you rock!
Any idea how to stop it while puppetteer is running such that it won't close the console? Must be something to do with the communication with node.
Also - is there a way to pass timeout to @page.wait_for_selector? This works in node but ruby seems to only allow one argument.
@page.wait_for_selector '#add-new-address', {timeout: 60000}
gives:
/home/kevin/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/puppeteer-ruby-0.40.1/lib/puppeteer/page.rb:1235:in
wait_for_selector': wrong number of arguments (given 2, expected 1) (ArgumentError)`
Hi,
@page.wait_for_selector '#add-new-address', {timeout: 60000}
This code is valid on Ruby < 3, but not working on Ruby >=3. timeout
is defined as keyword parameter.
@page.wait_for_selector('#add-new-address', timeout: 60000)
would work as expected.
Another minor problem if you have any ideas - I'm running this from a rails console & ctrl+c is killing the whole process when I run it during a puppeteer wait. Is there any way to rescue this so I can cancel delays early when I realize it's going to fail?
Any idea how to stop it while puppetteer is running such that it won't close the console? Must be something to do with the communication with node.
Thank you for your feedback. I'd like to discuss about this in another issue if possible. Could you post a new issue for this?
Timeout - thanks! It's hard to tell the format for arguments with conversion libraries like this one, I appreciate the help.