karma-runner / karma

Spectacular Test Runner for JavaScript
http://karma-runner.github.io
MIT License
11.96k stars 1.71k forks source link

Karma fails to restart phantomjs after crash #2152

Open RodolpheGohard opened 8 years ago

RodolpheGohard commented 8 years ago

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

{
    // 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 commented 8 years ago

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 ?

jdmarshall commented 7 years ago

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.

mihirsoni commented 7 years ago

is there any update on this ?

CrazyBS commented 7 years ago

Still a problem

andrewminer commented 4 years ago

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.