twalpole / apparition

Capybara driver for Chrome using CDP
MIT License
363 stars 46 forks source link

WebSocket frame length too large (RuntimeError) #47

Closed calebkeene closed 4 years ago

calebkeene commented 4 years ago

I'm using apparition as my javascript driver for capybara in a suite of cucumber tests. I've got the tests running OK locally in both headless and non-headless mode, but I'm not having a problem on CI (codeship) which I'm not entirely sure how to fix.

here are the versions of the relevant gems being used (in no particular order other than perceived relevancy)

apparition (0.5.0)
      capybara (~> 3.13, < 4)
      websocket-driver (>= 0.6.5)
websocket-driver (0.7.1)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.4)
capybara (3.31.0)
      addressable
      mini_mime (>= 0.1.3)
      nokogiri (~> 1.8)
      rack (>= 1.6.0)
      rack-test (>= 0.6.3)
      regexp_parser (~> 1.5)
      xpath (~> 3.2)
puma (4.3.3)
      nio4r (~> 2.0)
cucumber (3.1.2)
      builder (>= 2.1.2)
      cucumber-core (~> 3.2.0)
      cucumber-expressions (~> 6.0.1)
      cucumber-wire (~> 0.0.1)
      diff-lcs (~> 1.3)
      gherkin (~> 5.1.0)
      multi_json (>= 1.7.5, < 2.0)
      multi_test (>= 0.1.2)
cucumber-api-steps (0.14.0)
      cucumber (>= 2.0.2)
      jsonpath (>= 0.1.2)
cucumber-core (3.2.1)
      backports (>= 3.8.0)
      cucumber-tag_expressions (~> 1.1.0)
      gherkin (~> 5.0)
cucumber-expressions (6.0.1)
cucumber-rails (1.7.0)
      capybara (>= 2.3.0, < 4)
      cucumber (>= 3.0.2, < 4)
      mime-types (>= 1.17, < 4)
      nokogiri (~> 1.8)
      railties (>= 4.2, < 7)
webpacker (4.0.7)
      activesupport (>= 4.2)
      rack-proxy (>= 0.6.1)
      railties (>= 4.2)
rails (6.0.2.1)
      actioncable (= 6.0.2.1)
      actionmailbox (= 6.0.2.1)
      actionmailer (= 6.0.2.1)
      actionpack (= 6.0.2.1)
      actiontext (= 6.0.2.1)
      actionview (= 6.0.2.1)
      activejob (= 6.0.2.1)
      activemodel (= 6.0.2.1)
      activerecord (= 6.0.2.1)
      activestorage (= 6.0.2.1)
      activesupport (= 6.0.2.1)
      bundler (>= 1.3.0)
      railties (= 6.0.2.1)
      sprockets-rails (>= 2.0.0)

here is my capybara driver configuration file

require 'capybara/apparition'

Capybara.default_max_wait_time = 10
Capybara.exact = false

Capybara.register_driver :apparition do |app|

  options = {
    headless: true,
    timeout: 15,
    browser_options: [
      :no_sandbox,
      :disable_gpu,
      { disable_features: 'VizDisplayCompositor' },
    ]
  }

  Capybara::Apparition::Driver.new(app, options)
end

Capybara.javascript_driver = :apparition
Capybara.server = :puma

chrome version on codeship: Google Chrome 80.0.3987.149 (not sure if this is relevant, this is the same as my local which is working fine)

here is the error I am presented with when starting any cucumber tests

#<Thread:0x0000564aab624390@/home/rof/cache/bundler/ruby/2.5.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:226 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
    17: from /home/rof/cache/bundler/ruby/2.5.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:228:in `block in start_threads'
    16: from /home/rof/cache/bundler/ruby/2.5.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:139:in `listen'
    15: from /home/rof/cache/bundler/ruby/2.5.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:128:in `read_until'
    14: from /home/rof/cache/bundler/ruby/2.5.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:128:in `loop'
    13: from /home/rof/cache/bundler/ruby/2.5.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:129:in `block in read_until'
    12: from /home/rof/cache/bundler/ruby/2.5.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/chrome_client.rb:143:in `read_msg'
    11: from /home/rof/cache/bundler/ruby/2.5.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/web_socket_client.rb:24:in `read_msg'
    10: from /home/rof/cache/bundler/ruby/2.5.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/web_socket_client.rb:58:in `parse_input'
     9: from /home/rof/cache/bundler/ruby/2.5.0/gems/websocket-driver-0.7.1/lib/websocket/driver/client.rb:63:in `parse'
     8: from /home/rof/cache/bundler/ruby/2.5.0/gems/websocket-driver-0.7.1/lib/websocket/driver/hybi.rb:104:in `parse'
     7: from /home/rof/cache/bundler/ruby/2.5.0/gems/websocket-driver-0.7.1/lib/websocket/driver/hybi.rb:327:in `parse_extended_length'
     6: from /home/rof/cache/bundler/ruby/2.5.0/gems/websocket-driver-0.7.1/lib/websocket/driver/hybi.rb:334:in `check_frame_length'
     5: from /home/rof/cache/bundler/ruby/2.5.0/gems/websocket-driver-0.7.1/lib/websocket/driver/hybi.rb:266:in `fail'
     4: from /home/rof/cache/bundler/ruby/2.5.0/gems/websocket-driver-0.7.1/lib/websocket/driver/hybi.rb:260:in `shutdown'
     3: from /home/rof/cache/bundler/ruby/2.5.0/gems/websocket-driver-0.7.1/lib/websocket/driver/event_emitter.rb:38:in `emit'
     2: from /home/rof/cache/bundler/ruby/2.5.0/gems/websocket-driver-0.7.1/lib/websocket/driver/event_emitter.rb:38:in `each'
     1: from /home/rof/cache/bundler/ruby/2.5.0/gems/websocket-driver-0.7.1/lib/websocket/driver/event_emitter.rb:39:in `block in emit'
/home/rof/cache/bundler/ruby/2.5.0/gems/apparition-0.5.0/lib/capybara/apparition/driver/web_socket_client.rb:40:in `block in setup_driver': WebSocket frame length too large (RuntimeError)

thanks!

twalpole commented 4 years ago

Could you please try the master branch and see if you have the same issue, although truthfully this error seems like it's possible not actually starting Chrome - is it possible there is a stub that's being started instead?

calebkeene commented 4 years ago

@twalpole putting gem 'apparition', git: 'git@github.com:twalpole/apparition.git', branch: 'master' gives 0.5.0, the same version I was getting off rubygems.org, still the same on CI. I don't believe there's any stubbing of chrome, not sure how that would work 🤔Any suggestions for possible debugging steps? I don't have a ton of time to dig around in the gem so I've been mostly treating it as a black box - I already spent time refactoring a bunch of tests so they wouldn't need selenium, hoping to not need to go back to that

twalpole commented 4 years ago

Yes the version will still show 0.5.0 but it will be the latest code - FYI you can just do gem 'apparition', github: 'twalpole/apparition' to get the master branch of a github repo . I don't know what to tell you about codeship, I don't use it, but I do know that other CI/CD providers do sometimes have stubs (scripts) in place of chrome in order to apply their own flags which can sometimes interfere.

calebkeene commented 4 years ago

@twalpole Yeah I just had gem 'apparition', git: 'git@github.com:twalpole/apparition.git', branch: 'master' to grab the latest. I'm fairly sure Codeship doesn't do any stubbing of chrome, the build VM seems to use both google-chrome and chromedriver binaries sitting in /usr/bin - both of which appear to be the same as the (almost) edge versions you'd get when downloading fresh. No worries if you don't have any other insights into the behaviour I'm seeing though, I'll have another poke around. Cheers

calebkeene commented 4 years ago

Closing this for now as I didn't make any progress on it and there don't appear to be any ideas forthcoming (I ended up switching back to selenium-webdriver in the end)