heroku / heroku-buildpack-google-chrome

[DEPRECATED] Classic buildpack that installs Google Chrome.
296 stars 365 forks source link

Headless Chrome hangs up forever #70

Closed neosepulveda closed 5 years ago

neosepulveda commented 5 years ago

Hi Heroku!

I just created a new Rails app and I added one system test using headless Chrome. The test suite run perfectly well on localhost but in Heroku CI hangs up forever. I followed a few setups and configurations that I've seen around, however, I always end up in the same point.

heroku ci:debug --pipeline foo

$ bundle exec rspec spec/system/react_status_spec.rb 
DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the view object and the source for the view object.
Change:
  >> JbuilderHandler.call(template)
To:
  >> JbuilderHandler.call(template, source)
 (called from <top (required)> at /app/config/environment.rb:7)
DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the view object and the source for the view object.
Change:
  >> JbuilderHandler.call(template)
To:
  >> JbuilderHandler.call(template, source)
 (called from <main> at /app/config/environment.rb:7)
Capybara starting Puma...
* Version 3.12.1 , codename: Llamas in Pajamas
* Min threads: 0, max threads: 4
* Listening on tcp://127.0.0.1:46206

DevTools listening on ws://127.0.0.1:9222/devtools/browser/21f03248-bfc5-4fbc-8b07-542888f4ac9e

It hangs up indefinitely after displaying DevTools listening on ws://127.0.0.1:9222/devtools/browser/21f03248-bfc5-4fbc-8b07-542888f4ac9e. It never times out or displays an error.

This is Capybara-Chrome driver configuration

# frozen_string_literal: true

require 'selenium/webdriver'
require 'capybara-screenshot/rspec'
Capybara.javascript_driver = :selenium_chrome_headless

Capybara::Screenshot.register_driver(:selenium_chrome_headless) do |driver, path|
  driver.browser.save_screenshot(path)
end

RSpec.configure do |config|
  config.before(:each, type: :system) do
    driven_by(:rack_test)
  end

  config.before(:each, type: :system, js: true) do
    driven_by(:selenium_chrome_headless)
  end
end

This is my app.json heroku Ci file

  "environments": {
    "test": {
      "addons": [
        "heroku-postgresql"
      ],
      "scripts": {
        "test": "bundle exec rspec"
      },
      "formation": {
        "test": {
          "quantity": 1,
          "size": "standard-1x"
        }
      },
      "buildpacks": [
        { "url": "heroku/ruby" },
        { "url": "heroku/nodejs" },
        { "url": "https://github.com/heroku/heroku-buildpack-google-chrome" },
        { "url": "https://github.com/heroku/heroku-buildpack-chromedriver" }
      ]
    }
  }

Any ideas of what is causing this problem?

Thank you very much in advance ❤️

rubendinho commented 5 years ago

@neosepulveda There have been a bunch of problems related to - i think - a change in how Google publishes version numbers.

Try setting your chrome driver version explicitly. Per https://github.com/heroku/heroku-buildpack-chromedriver, that would involve setting CHROMEDRIVER_VERSION explicitly to the latest stable version. As of this writing, that's "74.0.3729.6"

Possibly related: https://github.com/titusfortner/webdrivers/issues/72

neosepulveda commented 5 years ago

@rubendinho Thanks for the quick reply. I tried using the stable release in the path or specifying the version as mentioned in the issue your referenced but no luck...

As a reference for other people who stumble into this, this is what I tried and did not work:

Selenium::WebDriver::Chrome.path = '/app/.apt/usr/bin/google-chrome-stable'
Webdrivers::Chromedriver.version = '2.46'

@rubendinho How do you exactly specify what CHROMEDRIVER_VERSION to use? Thanks

rubendinho commented 5 years ago

You’re using the chromedriver buildpack so I would set that as an environment variable per their instructions.

The Webdrivers config is not likely to work unless you’re using that gem.

Try setting a config variable in your app.json or the Heroku CI GUI to the version I referenced which is the current stable release.

On May 1, 2019, at 7:40 PM, Neo Sepulveda notifications@github.com wrote:

@rubendinho Thanks for the quick reply. I tried using the stable release in the path or specifying the version as mentioned in the issue your referenced but no luck...

As a reference for other people who stumble into this, this is what I tried and did not work:

Selenium::WebDriver::Chrome.path = '/app/.apt/usr/bin/google-chrome-stable' Webdrivers::Chromedriver.version = '2.46' @rubendinho How do you exactly specify what CHROMEDRIVER_VERSION to use? Thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

neosepulveda commented 5 years ago

HI @rubendinho, I tried your suggestion and still not working unfortunately.

Here is the log log

-----> Downloading chromedriver v74.0.3729.6...
Archive:  /tmp/chromedriver.zip
  inflating: /app/.chromedriver/bin/chromedriver  
-----> Creating chromedriver export scripts...
-----> No test-setup command provided. Skipping.
-----> Run `eval $(ci env)` to set up your environment for running tests

~ $ bundle exec rspec 
Capybara starting Puma...
* Version 3.12.1 , codename: Llamas in Pajamas
* Min threads: 0, max threads: 4
* Listening on tcp://127.0.0.1:37885
2019-05-02 09:25:32 DEBUG Webdrivers Looking for Site: https://chromedriver.storage.googleapis.com
2019-05-02 09:25:32 DEBUG Webdrivers Get response: #<Net::HTTPOK 200 OK readbody=true>
2019-05-02 09:25:32 DEBUG Webdrivers Found Site: https://chromedriver.storage.googleapis.com
2019-05-02 09:25:32 DEBUG Webdrivers Looking for Site: https://chromedriver.storage.googleapis.com
2019-05-02 09:25:33 DEBUG Webdrivers Get response: #<Net::HTTPOK 200 OK readbody=true>
2019-05-02 09:25:33 DEBUG Webdrivers Found Site: https://chromedriver.storage.googleapis.com
2019-05-02 09:25:33 DEBUG Webdrivers Browser executable: '/app/.apt/usr/bin/google-chrome'

DevTools listening on ws://127.0.0.1:9222/devtools/browser/dae2e479-2f5c-4bfa-b403-f7011bdb1a21

FYI, I am using webdrivers gem as you said

kapoorlakshya commented 5 years ago

The webdrivers related problem has been solved - https://github.com/titusfortner/webdrivers/issues/72

neosepulveda commented 5 years ago

Closing this issue as it has been solved in https://github.com/titusfortner/webdrivers/issues/72