Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Don't exit process when single-run #3

Closed
petebacondarwin opened this issue Apr 13, 2014 · 17 comments
Closed

Don't exit process when single-run #3

petebacondarwin opened this issue Apr 13, 2014 · 17 comments
Labels

Comments

@petebacondarwin
Copy link

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
Copy link

+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 <
[email protected]> 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//issues/3
.

@pkozlowski-opensource
Copy link
Member

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
Copy link

lazd commented Apr 18, 2014

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
Copy link
Member

@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: karma-runner/karma#1035

@pkozlowski-opensource
Copy link
Member

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 (karma-runner/karma#1054) but the remaining timeout is only 2s to things are usable now even with this timeout.

@vojtajina
Copy link

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

@zellwk
Copy link

zellwk commented Aug 25, 2015

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
Copy link

zellwk commented Aug 25, 2015

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

@hrajchert
Copy link

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
Copy link

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

@lazd
Copy link

lazd commented Jun 14, 2016

This module is deprecated.

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

@johannesjo
Copy link

johannesjo commented Jun 14, 2016

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

@johannesjo
Copy link

This is possibly a duplicate of karma-runner/karma#1788

@gandra
Copy link

gandra commented Feb 3, 2017

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
Copy link

ovod88 commented Jul 22, 2017

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

@Jeff-Tian
Copy link

Bump

@johnjbarton
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests