karma-runner / karma-phantomjs-launcher

A Karma plugin. Launcher for PhantomJS.
MIT License
281 stars 122 forks source link

exitOnResourceError causes PhantomJS to crash #125

Open jameshartig opened 8 years ago

jameshartig commented 8 years ago

I'm using v1.0.0 of the launcher, v0.13.22 of Karma and v2.1.1 of PhantomJS. I'm running Windows 10 64-bit and Node v4.4.5.

Whenever I set exitOnResourceError to true in the phantomjsLauncher object in my Karma config, PhantomJS just immediately crashes. If I set it to false, everything works fine. My phantomjsLauncher is empty except for that key:

  phantomjsLauncher: {
    // Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
    exitOnResourceError: true
  },

I'm not using any custom PhantomJS browser options, just the default --browers PhantomJS.

Is there anything else I can do to help debug? I'm not seeing anything in the output from Karma that's helpful:

> karma start --single-run --browsers PhantomJS
START:
20 06 2016 14:14:33.679:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
20 06 2016 14:14:33.687:INFO [launcher]: Starting browser PhantomJS
20 06 2016 14:14:35.320:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket /#wTksIo_LG6M59w7PAAAA with id 53610116
20 06 2016 14:14:35.510:ERROR [launcher]: PhantomJS crashed.

20 06 2016 14:14:35.515:INFO [launcher]: Trying to start PhantomJS again (1/2).
20 06 2016 14:14:47.105:WARN [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Disconnected (1 times), because no message in 10000 ms.
ciwchris commented 8 years ago

You could try setting --log-level=debug to collect more details.

jameshartig commented 8 years ago

Thanks @ciwchris after enabling debug I realized there was 404 errors for an image. After fixing that it's no longer crashing. Derp.

jameshartig commented 8 years ago

Okay so I got it working but as soon as I start using source files that are served via karma it starts crashing again. I don't see any 404 errors anymore and the files its serving do exist.

> karma start --single-run --browsers PhantomJS --log-level=debug
23 06 2016 00:12:14.852:DEBUG [config]: autoWatch set to false, because of singleRun
23 06 2016 00:12:14.859:DEBUG [plugin]: Loading plugin karma-chrome-launcher.
23 06 2016 00:12:14.873:DEBUG [plugin]: Loading plugin karma-phantomjs-launcher.
23 06 2016 00:12:14.948:DEBUG [plugin]: Loading plugin karma-browserstack-launcher.
23 06 2016 00:12:15.163:DEBUG [plugin]: Loading plugin karma-mocha.
23 06 2016 00:12:15.166:DEBUG [plugin]: Loading plugin karma-mocha-reporter.
23 06 2016 00:12:15.187:DEBUG [plugin]: Loading plugin karma-sourcemap-loader.
23 06 2016 00:12:15.190:DEBUG [plugin]: Loading plugin karma-webpack.
23 06 2016 00:12:15.291:DEBUG [plugin]: Loading inlined plugin (defining launcher:Chrome_hidden, launcher:bs_firefox_mac, launcher:bs_chrome_mac, launcher:bs_ie6, launcher:bs_ie7, launcher:bs_ie8, launcher:bs_ie9, launcher:bs_ie10, launcher:bs_ie11, launcher:bs_safari91, launcher:bs_safari8, launcher:bs_safari71, launcher:bs_safari62).
START:
23 06 2016 00:12:18.729:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
23 06 2016 00:12:18.737:INFO [launcher]: Starting browser PhantomJS
23 06 2016 00:12:18.738:DEBUG [temp-dir]: Creating temp dir at C:\Users\james\AppData\Local\Temp\karma-64221764
23 06 2016 00:12:18.750:DEBUG [launcher]: c:\Users\james\Dropbox\aftermath\swazzal\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe C:\Users\james\AppData\Local\Temp\karma-64221764/capture.js
23 06 2016 00:12:20.435:DEBUG [web-server]: serving: c:\Users\james\Dropbox\aftermath\swazzal\node_modules\karma\static/client.html
23 06 2016 00:12:20.454:DEBUG [web-server]: serving: c:\Users\james\Dropbox\aftermath\swazzal\node_modules\karma\static/karma.js
23 06 2016 00:12:20.517:DEBUG [karma]: A browser has connected on socket /#-DyndaHAEPYzzLkoAAAA
23 06 2016 00:12:20.524:DEBUG [web-server]: upgrade /socket.io/?EIO=3&transport=websocket&sid=-DyndaHAEPYzzLkoAAAA
23 06 2016 00:12:20.559:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket /#-DyndaHAEPYzzLkoAAAA with id 64221764
23 06 2016 00:12:20.560:DEBUG [launcher]: PhantomJS (id 64221764) captured in 1.83 secs
23 06 2016 00:12:20.568:DEBUG [phantomjs.launcher]: 
23 06 2016 00:12:20.571:DEBUG [web-server]: serving: c:\Users\james\Dropbox\aftermath\swazzal\node_modules\karma\static/context.html
23 06 2016 00:12:20.574:DEBUG [middleware:source-files]: Requesting /absolutec:/Users/james/Dropbox/aftermath/swazzal/node_modules/mocha/mocha.js?91557a9e8a222ad90c0392709844a7c448515b9d /
23 06 2016 00:12:20.575:DEBUG [middleware:source-files]: Fetching c:/Users/james/Dropbox/aftermath/swazzal/node_modules/mocha/mocha.js
23 06 2016 00:12:20.576:DEBUG [web-server]: serving (cached): c:/Users/james/Dropbox/aftermath/swazzal/node_modules/mocha/mocha.js
23 06 2016 00:12:20.580:DEBUG [middleware:source-files]: Requesting /absolutec:/Users/james/Dropbox/aftermath/swazzal/node_modules/karma-mocha/lib/adapter.js?31f96783c9ff890968c2d07292de7a74310560f1 /
23 06 2016 00:12:20.581:DEBUG [middleware:source-files]: Fetching c:/Users/james/Dropbox/aftermath/swazzal/node_modules/karma-mocha/lib/adapter.js
23 06 2016 00:12:20.581:DEBUG [web-server]: serving (cached): c:/Users/james/Dropbox/aftermath/swazzal/node_modules/karma-mocha/lib/adapter.js
23 06 2016 00:12:20.582:DEBUG [middleware:source-files]: Requesting /absolutec:/Users/james/Dropbox/aftermath/swazzal/test/index.js?d9915ec96ec2ae03a17afa2452c657283fa46fdb /
23 06 2016 00:12:20.582:DEBUG [middleware:source-files]: Fetching c:/Users/james/Dropbox/aftermath/swazzal/test/index.js
23 06 2016 00:12:20.582:DEBUG [web-server]: serving (cached): c:/Users/james/Dropbox/aftermath/swazzal/test/index.js
23 06 2016 00:12:20.671:DEBUG [middleware:source-files]: Requesting /base/foo.html /
23 06 2016 00:12:20.671:DEBUG [middleware:source-files]: Fetching c:/Users/james/Dropbox/aftermath/swazzal/test/static/foo.html
23 06 2016 00:12:20.672:DEBUG [web-server]: serving: c:/Users/james/Dropbox/aftermath/swazzal/test/static/foo.html
23 06 2016 00:12:20.772:DEBUG [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Disconnected during run, waiting 2000ms for reconnecting.
23 06 2016 00:12:20.774:DEBUG [launcher]: Process PhantomJS exited with code 1
23 06 2016 00:12:20.775:ERROR [launcher]: PhantomJS crashed.
levithomason commented 8 years ago

I was just writing up a confirmation of this issue, then suddenly after a rebase it is gone :/ I was debugging with the log level, nothing of interest for me. PhantomJS was exiting with code 1.

Also, it would fail even when running only a single test file. Wish I had more to go on there, will report back if it comes up again.

levithomason commented 8 years ago

This just came up again, it was related to proxying image requests to a local folder. I've just removed the exitOnResourceError option for now since we aren't actually testing resources in our case.

ptim commented 7 years ago

It's a great relief to find this issue (workarounds), thanks! Confirming that removing exitOnResourceError prevents crashes for me, too...

dalgleish commented 7 years ago

I encountered the same issue, and setting exitOnResourceError to false prevents it.

It was caused by a 404 too, but I want the test to pass since the 404 is caused by mock data rendering <img> links, but that is inconsequential to the test.

Will try to provide more detail when I can look at it more.