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.

Karma fails to exit when run in xvfb under docker

See original GitHub issue

I’m not really sure where the issue is here. I am hoping someone can help me track it down.

I am using the following dockerfile in the root of my project:

FROM jeffutter/iojs-xvfb-chromium:onbuild

It appears to run the tests and then just hang. If I run with debug I get the following output:

# xvfb-run ./node_modules/.bin/karma start --no-auto-watch --single-run --log-level debug
DEBUG [config]: Loading config /usr/src/app/karma.conf.js
DEBUG [plugin]: Loading karma-* from /usr/src/app/node_modules
DEBUG [plugin]: Loading plugin /usr/src/app/node_modules/karma-browserify.
DEBUG [plugin]: Loading plugin /usr/src/app/node_modules/karma-chai.
DEBUG [plugin]: Loading plugin /usr/src/app/node_modules/karma-chai-plugins.
DEBUG [plugin]: Loading plugin /usr/src/app/node_modules/karma-chrome-launcher.
DEBUG [plugin]: Loading plugin /usr/src/app/node_modules/karma-mocha.
DEBUG [framework.browserify]: created browserify bundle: /tmp/c6c2759b5045eb10f25f97a7af247f50.browserify
DEBUG [framework.browserify]: add bundle to config.files at position 0
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
DEBUG [temp-dir]: Creating temp dir at /tmp/karma-58833755
DEBUG [launcher]: /chromium.sh --user-data-dir=/tmp/karma-58833755 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate http://localhost:9876/?id=58833755
DEBUG [framework.browserify]: building bundle
DEBUG [framework.browserify]: updating test/components/device/info.spec.js in bundle
DEBUG [framework.browserify]: bundling
DEBUG [web-server]: serving: /usr/src/app/node_modules/karma/static/client.html
DEBUG [web-server]: serving: /usr/src/app/node_modules/karma/static/karma.js
DEBUG [web-server]: upgrade /socket.io/1/websocket/TsVITH8qmIrhTSmulogn
DEBUG [karma]: A browser has connected on socket TsVITH8qmIrhTSmulogn
INFO [Chrome 40.0.2214 (Linux)]: Connected on socket TsVITH8qmIrhTSmulogn with id 58833755
DEBUG [launcher]: Chrome (id 58833755) captured in 2.286 secs
INFO [framework.browserify]: 2213167 bytes written (5.34 seconds)
INFO [framework.browserify]: bundle built
DEBUG [watcher]: Resolved files:
        /usr/src/app/node_modules/karma-chai-plugins/function-bind-polyfill.js
        /usr/src/app/node_modules/karma-chai-plugins/node_modules/chai/chai.js
        /usr/src/app/node_modules/karma-chai-plugins/chai-adapter.js
        /usr/src/app/node_modules/mocha/mocha.js
        /usr/src/app/node_modules/karma-mocha/lib/adapter.js
        /tmp/c6c2759b5045eb10f25f97a7af247f50.browserify
        /usr/src/app/test/components/device/info.spec.js
        /usr/src/app/node_modules/chai-as-promised/lib/chai-as-promised.js
DEBUG [web-server]: serving: /usr/src/app/node_modules/karma/static/context.html
DEBUG [web-server]: serving (cached): /usr/src/app/node_modules/karma-chai-plugins/function-bind-polyfill.js
DEBUG [web-server]: serving (cached): /usr/src/app/node_modules/karma-chai-plugins/node_modules/chai/chai.js
DEBUG [web-server]: serving (cached): /usr/src/app/node_modules/karma-chai-plugins/chai-adapter.js
DEBUG [web-server]: serving (cached): /usr/src/app/node_modules/mocha/mocha.js
DEBUG [web-server]: serving (cached): /usr/src/app/node_modules/karma-mocha/lib/adapter.js
DEBUG [web-server]: serving (cached): /tmp/c6c2759b5045eb10f25f97a7af247f50.browserify
DEBUG [web-server]: serving (cached): /usr/src/app/test/components/device/info.spec.js
DEBUG [web-server]: serving (cached): /usr/src/app/node_modules/chai-as-promised/lib/chai-as-promised.js
Chrome 40.0.2214 (Linux): Executed 4 of 4 SUCCESS (0.034 secs / 0.013 secs)
DEBUG [karma]: Run complete, exiting.
DEBUG [launcher]: Disconnecting all browsers
DEBUG [framework.browserify]: cleaning up

This is where it stops.

Here is my karma config

module.exports = function(config) {
    config.set({
        basePath: '',
        frameworks: ["browserify", "mocha", "chai",
            "chai-as-promised"
        ],
        files: [
            'test/**/*.spec.js'
        ],
        exclude: [],
        preprocessors: {
            'test/**/*.js': ['browserify']
        },
        '6to5Preprocessor': {
            options: {
                sourceMap: 'inline',
                modules: 'commonStandard',
                optional: ["asyncToGenerator"]
            },
        },
        'browserify': {
            debug: true,
            paths: ['javascript'],
            transform: [
                ["babelify", {
                    optional: ["asyncToGenerator"]
                }]
            ]
        },
        reporters: ['progress'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['Chrome'],
        browserNoActivityTimeout: 30000,
        singleRun: false
    });
};

This same config works fine outside of docker on archlinux.

If anyone can help me track down what is going on here. It would be greatly appreciated.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
mark-adamscommented, Apr 5, 2015

@jeffutter Looks like I got it figured out. The images I’ve created are working great now.

https://github.com/mark-adams/docker-chromium-xvfb

Looks like the issue had to do with Karma’s insistence on the browser processes being dead before it could quit. With your wrapper script (and my old one), Karma would send a SIGTERM signal to the wrapper script when it wanted to shut down the browser. This would kill the wrapper script but leave Chromium and xvfb running. I managed to get around the issue by having my script relay the SIGTERM signals to the child xvfb and Chromium processes.

0reactions
jeffuttercommented, Apr 5, 2015

Yep, that was it. Good catch and thank you. I’ll close this issue since it clearly isn’t Karma’s fault.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Karma fails to exit when run in xvfb under docker -
Karma fails to exit when run in xvfb under docker. ... I am using the following dockerfile in the root of my project:...
Read more >
Karma Chrome Headless not working on Jenkins
Based on issue Karma 1.6 breaks Headless support for Chrome created on ... However it failed when running as a Jenkins job with...
Read more >
markadams/chromium-xvfb - Docker Image
This Docker image provides a way to run a real Chromium / Chrome browser headless inside of a Docker container. If you're looking...
Read more >
Troubleshooting - Chrome Developers
js runtime of Google Cloud Run does not come with the system packages needed to run Headless Chrome. You will need to set...
Read more >
How to Run Karma Tests in a Docker Container - DZone
If your JavaScript code does not contain any ES5 or ES6 features, you can use PhantomJS as a testing browser. PhantomJS runs as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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