grunt-karma icon indicating copy to clipboard operation
grunt-karma copied to clipboard

Temporarily remove Grunt's uncaughtException listeners.

Open jpommerening opened this issue 10 years ago • 3 comments

As I mentioned in #93, Grunt's uncaughtException listeners fire before Karma gets a chance to stop the browsers it started.

The only fix that I can think of is removing Grunt's listners for as long as Karma is running. That way, Karma can gracefully handle a framework raising an error or the user pressing Ctrl-c.

I made a small gist to reproduce the problem: https://gist.github.com/jpommerening/10364033

After running npm install, running Grunt will (probably) produce the following output:

$ grunt
Running "karma:unicorns" (karma) task
INFO [karma]: Karma v0.12.6 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Linux)]: Connected on socket 8mpKEfFNXoO5vMb1GWU6 with id 2679007
PhantomJS 1.9.7 (Linux): Executed 1 of 1 SUCCESS (0.038 secs / 0 secs)

Running "karma:explosions" (karma) task
INFO [karma]: Karma v0.12.6 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Linux)]: Connected on socket uo1f5cVKNpntcOFnGWd8 with id 10877927
PhantomJS 1.9.7 (Linux): Executed 1 of 1 SUCCESS (0.039 secs / 0 secs)
Fatal error: Bam!

To try the same thing with the changes in this PR:

$ npm install grunt-karma@jpommerening/grunt-karma#fix-stray-browsers
...
$ grunt
...

jpommerening avatar Apr 10 '14 10:04 jpommerening

I added another commit to handle SIGINT / Ctrl-c.

Karma listens for SIGINT and takes care of stopping all the browsers. Grunt, however, does not. So after Karma finished, Grunt will just continue running its task queue.

Since Grunt does not listen for SIGINT one would expect Ctrl-c to exit the process immediately. The best we can do is to add our own SIGINT listener and exit the process after Karma is finished.

jpommerening avatar Apr 10 '14 13:04 jpommerening

This seems long dead, but we still get problems on our CI machine with browsers hanging around from grunt-karma failures. It would great to see this updated and merged.

TheSavior avatar Dec 04 '15 01:12 TheSavior

@jpommerening could you rebase this onto latest master please?

dignifiedquire avatar May 26 '16 09:05 dignifiedquire