-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add bail on load errors #2672
Add bail on load errors #2672
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
Travis build seems to be broken on master, let me know when it is fixed and I will rebase. Would love to get this merged. |
Any update on this? |
@yagudaev Thanks! I think a test for this issue is critical because we already are supposed to exit on load errors: Something like karma/test/e2e/launcher-error.feature but load-error.feature would be awesome. |
Sorry this did not work out. I'm going to close a lot of older pull requests as the source code has changed a lot over the last year. |
Problem description
If Karma receives an error during the load of one of the plugins it currently swallows that error and continues running other plugins and exits with a zero error code.
I discovered this by investigating a successful build that didn't run any test on CircleCI. Turns out CI servers need a non-zero exit code to mark a build as failed.
Webpack 1.0 had a similar issue and they introduced a bail option that is turned on by default in 2.0 with a workaround npm package for 1.0 called webpack-fail-plugin. It would catch errors in plugins like babel that are used to compile the assets. A syntax error in the source code would cause babel plugin to fail and webpack would swallow the exception unless the bail option is on or fail plugin is present. See: webpack/webpack#708
In the case of Karma the failure was in the PhantomJS npm package, where it could not locate the binary. It should have been a show stopper and reported a failure, but proceeded to load and execute the next plugins. See: karma-runner/karma-phantomjs-launcher#120
This is my first attempt at looking at Karma, so please forgive my ignorance. This PR is a suggested solution and will need adjustments with your help.
Outstanding questions:
TODOs (would love help):
Other related: codymikol/karma-webpack#66