Skip to content

feat(angular_devkit): stop blocking karma after compilation error #11181

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

Merged
merged 1 commit into from
Jun 10, 2018

Conversation

nicojs
Copy link
Contributor

@nicojs nicojs commented Jun 9, 2018

This PR removes the blocking of karma in case of compilation errors. This will not influence regular developer workflows (with ng test and ng test --single-run), but does help plugin creators relying on karma run functionality (with singleRun: false and watch: false).

Fixes #11170

@filipesilva
Copy link
Contributor

LGTM, thanks for improving this!

By the way, have you found a way to exit karma gracefully in a programmatic way? I haven't really found one that doesn't call process.exit.

@filipesilva filipesilva merged commit a11dddf into angular:master Jun 10, 2018
@nicojs
Copy link
Contributor Author

nicojs commented Jun 10, 2018

By the way, have you found a way to exit karma gracefully in a programmatic way? I haven't really found one that doesn't call process.exit.

No, that isn't possible (that I know of). The only way documented way to stop karma is using karma.stopper.stop(options, [callback=process.exit]). This command sends an HTTP request to the karma server (for example: HTTP GET http://localhost:3456/stop).

The callback parameter defaults to process.exit so you might think that you can override that behavior. However, this is only the callback received by the caller. If you look at the middleware handling the http request, you can see that it always calls process.kill:
https://github.com/karma-runner/karma/blob/e8ca4ecefe92bd28494467503b09f3588b787cf7/lib/middleware/stopper.js#L13

In most cases (stryker, ng test, ...) the process hosting the karma server is also the process that would be sending the stop command, so the callback isn't even executed in those cases, as process.kill already happened. We designed Stryker around this by sand boxing test runners into separate processes.

Karma deserves some more love from the open source community. Unfortunately, I don't have the time for it.

Btw, when is the next release of the Angular CLI? I can't wait to try it out with Stryker.

@nicojs nicojs deleted the 11170-dont-block-karma branch June 10, 2018 13:15
@filipesilva
Copy link
Contributor

Yeah that's the conclusion I got to as well, just wanted the double check if I was missing anything.

Next release of the CLI and devkit packages should be next week.

@nicojs
Copy link
Contributor Author

nicojs commented Jun 23, 2018

Next release of the CLI and devkit packages should be next week.

I see there is a new release:

image

However, the new code seems to be absent

image

@filipesilva Did something go wrong during release?

@nicojs
Copy link
Contributor Author

nicojs commented Jun 28, 2018

I see. It is released under the @next tag. Thanks for pointing that out to me @filipesilva, works like a charm!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't block karma on webpack compilation errors
3 participants