rubycdp / ferrum

Headless Chrome Ruby API
https://ferrum.rubycdp.com
MIT License
1.69k stars 120 forks source link

Browser start fails with JRuby on Windows #400

Open jemelyah opened 10 months ago

jemelyah commented 10 months ago

OS: Microsoft Windows Server 2019 Datacenter JRuby version: 9.3.7.0 Ferrum version: 0.13 Chrome version: 116.0.5845.187

I am running Ferrum with JRuby on Windows, here is the console output:

irb(main):001:0> require 'ferrum'
=> true
irb(main):002:0> Ferrum::Browser.new

DevTools listening on ws://127.0.0.1:58272/devtools/browser/7398fe06-bb62-4914-babc-fcf395f9aba0
Traceback (most recent call last):
       13: from C:/jruby-9.3.7.0/bin/jirb:13:in `<main>'
       12: from org/jruby/RubyKernel.java:1237:in `catch'
       11: from org/jruby/RubyKernel.java:1237:in `catch'
       10: from org/jruby/RubyKernel.java:1507:in `loop'
        9: from org/jruby/RubyKernel.java:1091:in `eval'
        8: from (irb):2:in `evaluate'
        7: from org/jruby/RubyClass.java:881:in `new'
        6: from C:/jruby-9.3.7.0/lib/ruby/gems/shared/gems/ferrum-0.13/lib/ferrum/browser.rb:131:in `initialize'
        5: from C:/jruby-9.3.7.0/lib/ruby/gems/shared/gems/ferrum-0.13/lib/ferrum/browser.rb:269:in `start'
        4: from C:/jruby-9.3.7.0/lib/ruby/gems/shared/gems/ferrum-0.13/lib/ferrum/browser/process.rb:27:in `start'
        3: from org/jruby/RubyKernel.java:1938:in `tap'
        2: from C:/jruby-9.3.7.0/lib/ruby/gems/shared/gems/ferrum-0.13/lib/ferrum/browser/process.rb:102:in `start'
        1: from C:/jruby-9.3.7.0/lib/ruby/gems/shared/gems/ferrum-0.13/lib/ferrum/browser/process.rb:157:in `parse_ws_url'
Ferrum::ProcessTimeoutError (Browser did not produce websocket url within 10 seconds, try to increase `:process_timeout`. See https://github.com/rubycdp/ferrum#customization)

I see that Chrome process starts and outputs to the same output (JRuby console), soparse_ws_url cannot receive the output line.

I have rewritten the process startup to use Java ProcessBuilder and write to a specific output file instead of a standard output device, which solves this particular issue. I will open a PR with a potential solution.