karma-runner / gulp-karma

Example of using Karma with Gulp.
310 stars 41 forks source link

Don't exit process when single-run #3

Closed petebacondarwin closed 10 years ago

petebacondarwin commented 10 years ago

I am pretty sure that karma will exit when it finishes a single run task. Assuming this is the case, we should not be calling process.exit() when the single run has completed. This would prevent any subsequent tasks from being run.

Instead we should make use of Gulp's async task support. You can get a done method from the task parameter list:

gulp.task('test', function (done) {
  karma.start(_.assign({}, karmaCommonConf, {singleRun: true}), done);
});

Have you tried this? Is there something funny about the karma server that doesn't exit cleanly?

vojtajina commented 10 years ago

+1 if there is anything funny about Karma not exitting cleanly, we should fix Karma

On Sun, Apr 13, 2014 at 11:50 AM, Pete Bacon Darwin < notifications@github.com> wrote:

I am pretty sure that karma will exit when it finishes a single run task. Assuming this is the case, we should not be calling process.exit() when the single run has completed. This would prevent any subsequent tasks from being run.

Instead we should make use of Gulp's async task support. You can get a done method from the task parameter list:

gulp.task('test', function (done) { karma.start(_.assign({}, karmaCommonConf, {singleRun: true}), done); });

Have you tried this? Is there something funny about the karma server that doesn't exit cleanly?

Reply to this email directly or view it on GitHubhttps://github.com/karma-runner/gulp-karma/issues/3 .

pkozlowski-opensource commented 10 years ago

OK, after digging into it some more I can confirm that something in karma blocks the node process from exiting. Not sure what is going on exactly, but after the web server's close event we are not getting process exit event.

Interestingly, if we remove flash from socket's transports, the whole process finally does exit, but after ~20s delay. Suspecting socket.io for now, but want to do a small reproduce scenario without gulp just to confirm that the pb is indeed on the karma's side.

lazd commented 10 years ago

This is the reason why gulp-karma spawns a child process -- there was no other way to get Karma to die without taking the whole process with it.

pkozlowski-opensource commented 10 years ago

@lazd correct. So there is an issue in Karma (IMO it is coming from socket.io, but need to confirm) that we need to fix: https://github.com/karma-runner/karma/issues/1035

pkozlowski-opensource commented 10 years ago

Yay! After tracking down all the crazy timeouts we've got a better integration story for gulp + karma. There is still one issue in Karma waiting to be merged (https://github.com/karma-runner/karma/pull/1054) but the remaining timeout is only 2s to things are usable now even with this timeout.

vojtajina commented 10 years ago

Great job @pkozlowski-opensource ! Btw. karma-runner/karma#1054 is merged as well.

zellwk commented 9 years ago

I have a problem here as well. I noticed that the process doesn't exit whenever I use jquery in my files:

here's the trace:

Firefox 36.0.0 (Mac OS X 10.10.0): Executed 4 of 4 SUCCESS (0.003 secs / 0.001 secs)
[14:12:46] Finished 'test' after 1.21 s

25 08 2015 14:12:56.838:WARN [Firefox 36.0.0 (Mac OS X 10.10.0)]: Disconnected (Firefox 36.0.0 (Mac OS X 10.10.0): Executed 4 of 4 DISCONNECTED (10.005 secs / 0.001 secs)
[14:12:56] 'test' errored after 11 s
[14:12:56] Error: 1
    at formatError (/usr/local/lib/node_modules/gulp/bin/gulp.js:169:10)
    at Gulp.<anonymous> (/usr/local/lib/node_modules/gulp/bin/gulp.js:195:15)
    at Gulp.emit (events.js:107:17)
    at Gulp.Orchestrator._emitTaskDone (/Users/zellwk/Projects/Automating Your Workflow/project/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
    at /Users/zellwk/Projects/Automating Your Workflow/project/node_modules/gulp/node_modules/orchestrator/index.js:275:23
    at finish (/Users/zellwk/Projects/Automating Your Workflow/project/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
    at cb (/Users/zellwk/Projects/Automating Your Workflow/project/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
    at removeAllListeners (/Users/zellwk/Projects/Automating Your Workflow/project/node_modules/karma/lib/server.js:325:7)
    at /Users/zellwk/Projects/Automating Your Workflow/project/node_modules/karma/lib/server.js:336:9
    at Server.<anonymous> (net.js:1376:9)
    at Server.g (events.js:199:16)
    at Server.emit (events.js:104:17)
    at net.js:1419:10
    at process._tickCallback (node.js:355:11)

Any ideas?

zellwk commented 9 years ago

My bad. Just realized this: You can't have console.log statements in your files, otherwise the above error will happen.

hrajchert commented 8 years ago

I don't think this issue is resolved. I have a publish task in my gulpfile and before I do that I want to run the unit test, but 2 seconds after they run, my process die :(.

Why does karma need to do a process.exit() if not in singlerun?

johannesjo commented 8 years ago

I'm still having the same issue. This is not resolved.

lazd commented 8 years ago

This module is deprecated.

@johannesjo Ah, sorry. Maybe there was a regression? I remember noting this was fixed when testing myself.

johannesjo commented 8 years ago

I mean this issue still stands when using karma directly as provided by the example.

johannesjo commented 8 years ago

This is possibly a duplicate of https://github.com/karma-runner/karma/issues/1788

gandra commented 7 years ago

Having the same issue with fresh new angular2 app made with angular cli: http://stackoverflow.com/questions/42030568/how-to-manage-to-exit-phantomjs-launcher-after-tests-execution

ovod88 commented 7 years ago

Hello. I have the same issue. Is it resolved?

Jeff-Tian commented 5 years ago

Bump

johnjbarton commented 5 years ago

This issue is old and closed. Please open a new one with recent version and fresh information.