question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ChromeHeadless (Puppeteer) not captured when running in docker

See original GitHub issue

Trying to convert my karma config from phantomjs to puppeteer but I’m facing issues when running my test suite. Here’s the log:

[18:25:41] Starting 'karma'...
29 01 2018 18:26:37.287:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
29 01 2018 18:26:37.289:INFO [launcher]: Launching browser ChromeHeadless with unlimited concurrency
29 01 2018 18:26:37.501:INFO [launcher]: Starting browser ChromeHeadless
29 01 2018 18:27:37.521:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
29 01 2018 18:27:39.527:WARN [launcher]: ChromeHeadless was not killed in 2000 ms, sending SIGKILL.
29 01 2018 18:27:41.532:WARN [launcher]: ChromeHeadless was not killed by SIGKILL in 2000 ms, continuing.

After debugging, the CHROME_BIN is available here: /tmp/webcore/node_modules/puppeteer/.local-chromium/linux-526987/chrome-linux/chrome

And the karma config are these:

{ action: 'run',
  singleRun: true,
  browsers: [ 'ChromeHeadless' ],
  reporters: [ 'junit', 'dots' ],
  configFile: '/tmp/webcore/test/unit/config/karma.conf' }

Also tried using a custom launcher with the --no-sandbox option, but same issue… 😕

Any help is definitely welcome.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:34
  • Comments:23

github_iconTop GitHub Comments

3reactions
cmacdonnachacommented, Jun 27, 2019

Same issue for me using Angular 7. Running docker inside Jenkins.

27 06 2019 10:06:05.618:INFO [karma-server]: Karma v4.0.1 server started at http://0.0.0.0:9876/
27 06 2019 10:06:05.622:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency unlimited
27 06 2019 10:06:05.659:INFO [launcher]: Starting browser ChromeHeadless
27 06 2019 10:09:35.725:WARN [launcher]: ChromeHeadless have not captured in 210000 ms, killing.
27 06 2019 10:09:37.728:WARN [launcher]: ChromeHeadless was not killed in 2000 ms, sending SIGKILL.
27 06 2019 10:09:39.731:WARN [launcher]: ChromeHeadless was not killed by SIGKILL in 2000 ms, continuing.

karma.conf.js:

const process = require('process');
process.env.CHROME_BIN = require('puppeteer').executablePath();

module.exports = function(config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('karma-spec-reporter'),
      require('@angular-devkit/build-angular/plugins/karma'),
    ],
    client: {
      clearContext: false, // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, '../coverage/my-project'),
      reports: ['html', 'lcovonly', 'text-summary'],
      fixWebpackSourcePaths: true,
    },
    reporters: ['spec'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_DEBUG,
    autoWatch: true,
    reportSlowerThan: 90,
    browsers: ['ChromeHeadlessNoSandbox'],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: ['--no-sandbox', '--disable-dev-shm-usage'],
      },
    },
    restartOnFileChange: true,
    captureTimeout: 210000,
    browserDisconnectTolerance: 3,
    browserDisconnectTimeout: 210000,
    browserNoActivityTimeout: 210000,
  });
};
3reactions
oorobetscommented, Apr 18, 2019

Had same problem, when I ran tests using Gitlab CI. I just added

before_script:
    - export CHROME_BIN=/usr/bin/google-chrome
Read more comments on GitHub >

github_iconTop Results From Across the Web

"ChromeHeadless have not captured in 60000 ms, killing ...
I am expecting the tests to run successfully in all three instances (local npm, local Gitlab Runner and remote Gitlab CI/CD pipeline). Currently ......
Read more >
Troubleshooting - Puppeteer
Chrome headless doesn't launch on UNIX​. Make sure all the necessary dependencies are installed. You can run ldd chrome | grep not on...
Read more >
browserless/chrome - Docker Image
An interactive puppeteer debugger, so you can see what the headless browser is doing and use its DevTools. Works with most headless libraries....
Read more >
Crafting the perfect container to play with a Headless Chrome
In the world of webdev, the ability to run quickly end-to-end tests ... and Docker - See "3 ways to securely use Chrome...
Read more >
Puppeteer - npm
Puppeteer runs in headless mode by default, but can be configured to run in full (non-headless) Chrome/Chromium.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found