karma icon indicating copy to clipboard operation
karma copied to clipboard

Karma fails to restart phantomjs after crash

Open RodolpheGohard opened this issue 8 years ago • 5 comments

Expected behavior

I expect karma to be able to restart phantomjs, as it tries to, whenever phantomjs crashes(which is commonplace).

Actual behavior

After a PhantomJs crash, karma tries and fails to restart it two times. Consider this log:

PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 461 of 1279 (50 FAILED) (skipped 8) (0 secs / 10.394 secs)
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 462 of 1279 (50 FAILED) (skipped 8) (0 secs / 10.409 secs)
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 463 of 1279 (50 FAILED) (skipped 8) (0 secs / 10.424 secs)
27 05 2016 09:48:51.138:ERROR [launcher]: PhantomJS crashed.

27 05 2016 09:48:51.146:INFO [launcher]: Trying to start PhantomJS again (1/2).
27 05 2016 09:48:57.147:WARN [launcher]: PhantomJS have not captured in 6000 ms, killing.
27 05 2016 09:48:57.164:INFO [launcher]: Trying to start PhantomJS again (2/2).
27 05 2016 09:49:03.165:WARN [launcher]: PhantomJS have not captured in 6000 ms, killing.
27 05 2016 09:49:03.188:ERROR [launcher]: PhantomJS failed 2 times (timeout). Giving up.

Enviroment Details

Windows 7 SP1 64bits Intel Core i7 16Gb

package.json 's depencies

{
    "karma": "^0.13.21",
    "karma-babel-preprocessor": "~6.0.1",
    "karma-chai-plugins": "^0.7.0",
    "karma-chrome-launcher": "^1.0.1",
    "karma-coverage": "^0.5.3",
    "karma-htmlfile-reporter": "^0.2.2",
    "karma-jasmine": "^0.3.6",
    "karma-junit-reporter": "^0.3.8",
    "karma-ng-html2js-preprocessor": "^0.2.0",
    "karma-phantomjs-launcher": "^0.2.1",
    "karma-phantomjs-shim": "^1.1.2"
}
$ ./node_modules/karma/bin/karma --version
Karma version: 0.13.22

PhantomJS version: 1.9.20

  • Relevant part of your karma.config.js file
{
    // web server port
    port: 3030,
    // runner port
    runnerPort: 3031,

    captureTimeout: 6000,

    plugins: [
      'karma-chai-plugins',
      'karma-coverage',
      'karma-htmlfile-reporter',
      'karma-jasmine',
      'karma-junit-reporter',
      'karma-ng-html2js-preprocessor',
      'karma-phantomjs-launcher',
      'karma-chrome-launcher',
      'karma-phantomjs-shim'
    ],

 /// [...]
}

Notes

Running the tests with chrome works. I've seen others bugs with PhantomJs capture timeouts, but here the thing is that it succeeds at first, but then fails on retries. So the configuration must be right

RodolpheGohard avatar May 27 '16 08:05 RodolpheGohard

I tried with chrome and simulated a crash by killing chrome process. It's the same:

Chrome 48.0.2564 (Windows 7 0.0.0): Executed 295 of 1279 (60 FAILED) (skipped 8) (0 secs / 4.933 secs)
27 05 2016 10:25:44.534:ERROR [launcher]: Chrome crashed.

27 05 2016 10:25:44.646:INFO [launcher]: Trying to start Chrome again (1/2).
27 05 2016 10:25:50.647:WARN [launcher]: Chrome have not captured in 6000 ms, killing.
27 05 2016 10:25:50.747:INFO [launcher]: Trying to start Chrome again (2/2).
27 05 2016 10:25:56.747:WARN [launcher]: Chrome have not captured in 6000 ms, killing.
27 05 2016 10:25:56.850:ERROR [launcher]: Chrome failed 2 times (timeout). Giving up.

I saw that karma actually opened chrome browser twice. So maybe something's wrong in the capture ?

RodolpheGohard avatar May 27 '16 08:05 RodolpheGohard

I believe this is the problem:

In BaseLauncher, restart() calls self.start, which should emit a new start() event and cause the _start() functions to be called in the custom launchers. But the event only fires the first time, so _start() is never invoked by restart()

It may be that a different restart mechanism is needed.

jdmarshall avatar Dec 02 '16 01:12 jdmarshall

is there any update on this ?

mihirsoni avatar Apr 01 '17 11:04 mihirsoni

Still a problem

CrazyBS avatar May 02 '17 03:05 CrazyBS

FWIW, I'm still seeing this problem using ChromeHeadless. Most commonly this results when the test runner (mocha, in my case) hangs waiting on a promise which never resolves (due to an error) in a beforeEach block.

andrewminer avatar Apr 02 '20 01:04 andrewminer