Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karma does not exit gracefully #219

Closed
filipesilva opened this issue Sep 28, 2018 · 1 comment
Closed

Karma does not exit gracefully #219

filipesilva opened this issue Sep 28, 2018 · 1 comment

Comments

@filipesilva
Copy link

filipesilva commented Sep 28, 2018

When the Karma server is run programmatically, there is no way to request it to stop and be informed of when that has happened:

const karma = require('karma');
const karmaServer = new karma.Server({ singleRun: false, configFile: __dirname + '/karma.conf.js' });
karmaServer.start();
// How to stop the server, and be informed when cleanup is finished?
// karma.stop(() => console.log('server exited gracefully'));

To reproduce, follow these steps:

git clone https://github.com/filipesilva/karma-exit-gracefully
cd karma-exit-gracefully
npm install
npm test

Having a way to gracefully stop Karma is useful when the Karma run is part of more complex orchestration, like in gulp or @angular/cli.

There is a way to stop the server by calling karma stop, but that will kill the process altogether:

https://github.com/karma-runner/karma/blob/6742ecfbc9501a454430cbb3b814be28f459cb38/lib/middleware/stopper.js#L11-L13

There's some cleanup logic as well, but it only runs on --single-run:

https://github.com/karma-runner/karma/blob/6742ecfbc9501a454430cbb3b814be28f459cb38/lib/server.js#L289-L292

Related to karma-runner/karma#2867, ampproject/amphtml#14814

@filipesilva
Copy link
Author

Sorry, opened this issue on the wrong repo! Wanted to open in https://github.com/karma-runner/karma instead.

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

No branches or pull requests

1 participant