Karma: Karma doesn't start server in browsers

Created on 16 Dec 2014  Â·  30Comments  Â·  Source: karma-runner/karma

I'm having a problem where karma never actually starts the server. It seems to start the browsers, but never the server. I've tested in Chrome, and after it's launched the http://localhost:9876/ never loads. Running on windows 8, and node 0.10.33

The weird part is, I have the same exact configuration for grunt-karma, and it works no problem.

I get the error below:

INFO [karma]: Karma v0.12.28 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [launcher]: Starting browser Chrome
WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
WARN [launcher]: PhantomJS was not killed in 2000 ms, sending SIGKILL
WARN [launcher]: Chrome was not killed in 2000 ms, sending SIGKILL.

Here is my package.json for karma

"karma": "^0.12.3",
"karma-chrome-launcher": "^0.1.3",
"karma-coverage": "^0.2.1",
"karma-jasmine": "^0.1.5",
"karma-ng-html2js-preprocessor": "^0.1.0",
"karma-phantomjs-launcher": "^0.1.4",

Most helpful comment

I'm having the same issue on debian:

06 04 2016 14:30:43.056:WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
06 04 2016 14:30:45.062:WARN [launcher]: PhantomJS was not killed in 2000 ms, sending SIGKILL.
06 04 2016 14:30:47.068:WARN [launcher]: PhantomJS was not killed by SIGKILL in 2000 ms, continuing.

Did anyone solve this?

All 30 comments

same issue

@vernak2539 @taichi can you create minimal gist which reproduce this problem?
This will allow faster to deal with the problem.

Thanks!

@maksimr I've created this gist for it.

While I was making it, it actually worked, but it took 10min to run the code and get to the last part on the console_output file. This causes our build to error, in addition to slowing down development.

Thanks!

@vernak2539 Try remove coverage. Seems code coverage slow down tests.

@maksimr same exact thing happened. Same output. Just this time it took around 6 min.

@vernak2539 try run karma in debug mode karma start --log-level=debug.

What does FileFinder?
How much time it spend to find files?

FileFinder just generates an array of files that need to be loaded. Doesn't take long whatsoever.

After running with debug, this is what I think. We're getting karma to load a good amount of files. It seems that the browser's time out before all the files are actually loaded. Then once it finished loading the files, it again tries to start the browsers. This time it works, and executes the tests.

The weird thing about this, it that it doesn't happen when grunt runs karma. Not sure how there would be this big of a difference.

@maksimr so anything come up relating to this? Is it just something we have to deal with?

@vernak2539 It's hard for me to say something sorry.
The best case is to look at the project.

Are you tried run on linux?

Thanks!

Sorry, but I'm closing this due to inactivity. Please feel free to reopen with new details.

I'm having the same issue on debian:

06 04 2016 14:30:43.056:WARN [launcher]: PhantomJS have not captured in 60000 ms, killing.
06 04 2016 14:30:45.062:WARN [launcher]: PhantomJS was not killed in 2000 ms, sending SIGKILL.
06 04 2016 14:30:47.068:WARN [launcher]: PhantomJS was not killed by SIGKILL in 2000 ms, continuing.

Did anyone solve this?

Why closing this issue if is still happening? Same WARN messages as the above user, but with CHROME instead of PhantomJS

@nicopeeters We had to split out our test running into batches. Seems the amount of files loaded when doing them all at once was too much. not sure if it applies to you, but if so. Not the best solution to be honest

same issue on Mac

OS X 10.9.5 - same issue here

I too am seeing the same issue as nicopeeters on the same environment.

same issue

Guys, if you have problem please open another issue because reasons could be different.

Thanks

Hi, I have the same problem with you , have you fixed it?

Same problem here...

Same problem here

30 07 2017 17:23:55.837:WARN [launcher]: Firefox was not killed in 2000 ms, sending SIGKILL.
30 07 2017 17:23:57.841:WARN [launcher]: Firefox was not killed by SIGKILL in 2000 ms, continuing.

Same problem. Chrome works fine.

02 08 2017 11:05:50.036:WARN [launcher]: Firefox have not captured in 60000 ms, killing.
02 08 2017 11:05:52.038:WARN [launcher]: Firefox was not killed in 2000 ms, sending SIGKILL.
02 08 2017 11:05:54.040:WARN [launcher]: Firefox was not killed by SIGKILL in 2000 ms, continuing.

+1
Same problem. Chrome works fine.

02 08 2017 11:05:54.040:WARN [launcher]: Firefox was not killed by SIGKILL in 2000 ms, continuing.

Same here and resolved. There was no Firefox browsers in my server just in my case.

Same problem, did anyone resolve this issue?

Hi, Did any one resolve this issue?

I had faced this issue in ChromeHeadless Browser

image

Same problem I don't know anymore how to solve it. Since I the error message is too ambiguous.

> ng test --browsers ChromeHeadless --single-run=true

20 03 2018 14:56:41.565:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
20 03 2018 14:56:41.567:INFO [launcher]: Launching browser ChromeHeadless with unlimited concurrency
20 03 2018 14:56:41.573:INFO [launcher]: Starting browser ChromeHeadless
20 03 2018 14:57:41.575:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
20 03 2018 14:57:41.600:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
20 03 2018 14:58:41.630:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
20 03 2018 14:58:41.665:INFO [launcher]: Trying to start ChromeHeadless again (2/2).
20 03 2018 14:59:41.675:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
20 03 2018 14:59:41.695:ERROR [launcher]: ChromeHeadless failed 2 times (timeout). Giving up.
npm ERR! code ELIFECYCLE

Trying to use a custom launcher in karma.conf.js:

    customLaunchers: {
      ChromiumNoSandbox: {
        base: 'ChromiumHeadless',
        flags: ['--no-sandbox']
      }
    },
    browsers: ['ChromeHeadless',  'ChromiumNoSandbox'],

@danger89
Hi Melroy, to answer my own question..

  1. Remove the whole node_modules folder
  2. If you didn't add puppeteer yet to the devdeps, run: npm i --save-dev puppeteer
  3. Set the NODE_ENV correctly! Run: export NODE_ENV=development
  4. npm install
  5. Enable userns in the kernel (Debian only?):
    echo 'kernel.unprivileged_userns_clone=1' > /etc/sysctl.d/00-local-userns.conf
    service procps restart
  6. Run the headless Chrome browser test: ng test --browsers ChromeHeadless --single-run=true

As you may noticed. I am using puppeteer to get the Chromium binary from the internet.
My karma.conf.js looks like:

// Set the CHROME_BIN
process.env.CHROME_BIN = require('puppeteer').executablePath()

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma')
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    customLaunchers: {
      ChromeDebugging: {
        base: 'Chrome',
        flags: ['--remote-debugging-port=9222']
      },
      ChromiumNoSandbox: {
        base: 'ChromiumHeadless',
        flags: ['--no-sandbox']
      }
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['ChromeHeadless', 'ChromeDebugging', 'ChromiumNoSandbox'],
    singleRun: false
  })
}

Now it works!?

same issue, linux

I encountered the same issue. What helped me:

  1. Remove node_modules folder completely.
  2. Run npm install.

Apparently karma files got corrupted and couldn't be fixed automatically.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TKTheTechie picture TKTheTechie  Â·  4Comments

simonh1000 picture simonh1000  Â·  3Comments

jhildenbiddle picture jhildenbiddle  Â·  4Comments

danielsiwiec picture danielsiwiec  Â·  5Comments

ORESoftware picture ORESoftware  Â·  4Comments