-
Notifications
You must be signed in to change notification settings - Fork 220
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
bail option does not exit the process #66
Comments
I'm having the same problem. We're not running the webpack CLI, but using it programmatically in our builds.
|
As mentioned in #49, these two plugins might help solving this issue: https://gist.github.com/Stuk/6b574049435df532e905 |
Workarounds aside, we should be respecting the bail option inside the loader no? |
@d3viant0ne Most certainly! I kind of just pinned those plugins for reference thinking they might be useful while investigating a fix. I'd say this is a pretty high priority fix. I'd hate to have something deploy even though tests fail. |
Hi! I have a same problem but with tslint: {
configuration: require('../tslint.json'),
emitErrors: true,
failOnHint: true
} I receive messages like "Module build failed: Error: Compilation failed due to tslint errors." but karma-webpack keep running. |
I wrote and published a plugin on NPM that solves this problem for my own needs. It propagates warnings and errors up to the console and ends the process with a non-zero exit code if it encounters an error. If anyone else is interested in it, it's webpack-karma-die-hard. |
For what it's worth |
It still going to stay in the milestone so I can at the very least remember to cover the use case with a few integration tests. |
This config is working for me using webpack2:
|
I can't seem to get Instead, when I run Karma with
|
I've moved this into the org maintainers priority list. One of us, most likely me will get this sorted and out in |
Hey that's nice to hear, thank you! |
Having the same issue. It is tied to: webpack/webpack#708. For us our CI server fails on trying to load phantomjs but still shows the tests pass. See karma-runner/karma-phantomjs-launcher#120 Turns out it is Karma that swallows those errors, I created a PR for it: karma-runner/karma#2672 You can try it locally by using my fork: yarn remove karma
yarn add nano3labs/karma.git#bail-on-load-error |
/cc @d3viant0ne Do I right believe that this problem exists in all loaders? |
Some, others have hacks in place to work around the issue. |
can reproduce this in 2.0.4 version with tslint-loader |
We're having the same issue and I can confirm that setting The specific error that was an Versions:
|
This is still not working with This is really annoying in |
I also tried setting It seems like |
👍 Facing this issue as well :/ |
I am also having this issue. |
I'm facing this issue as well. We use I have compilation error available here in But the What kinda worked in my case was adding
I need to pause my investigation for now, will try to create a small repo to reproduce the problem I experience later this week. |
I've prepared a minimal repo where you can reproduce the issue. https://github.com/ertrzyiks/karma-webpack-failed-compilation-example |
Could we have an update on this issue? At some point it was assigned, supposed to go out in 2.0.4, but then it was unassigned. It still has a hotlist label. Is there any plan to fix this issue? |
Do you have any update on this issue? |
Is there any workaround for this for Webpack 4? The plugins mentioned previously don't seem to work for me -- build completely hangs on any webpack compilation error as previously described and makes CI a total pain to deal with.
|
@Ivaylo-Lafchiev I've been using this plugin lately:
Hope it helps. |
Appreciate the reply, but this isn't suitable for our use case as karma runs as part of a gulp pipeline and this would just exit the entire pipeline as opposed to move onto the next task.
Specifically, webpackConfig.mode = 'development' seems to solve it. Unfortunately, karma will still go on to run the tests even after webpack fails to compile but at least the process exits gracefully now. |
As long as codymikol#66 (which is about `bail` not being honored by webpack) is not fixed, we can emulate equivalent behavior inside the plugin as an alternative solution. If the webpack compilation step finishes with errors and the `bail` option is set to true, we exit Karma with a nonzero exit status. This way, we can still prevent Karma from silently continuing upon webpack compilation errors.
Improving on @teogeos's comment, if you'd rather have Webpack output its colored text to the console before exiting, then you can do this instead: new (class ExitOnErrorWebpackPlugin {
apply(compiler) {
compiler.hooks.done.tap('ExitOnErrorWebpackPlugin', stats => {
if (stats && stats.hasErrors()) {
// Exit in the next microtask, so that Webpack has a chance to write to stderr
Promise.resolve().then( () => process.exit(1) )
}
})
}
})(), |
Note: Sometimes (for example, for missing files) you will never reach the class FailBailPlugin {
apply(compiler) {
compiler.hooks.failed.tap('FailBailPlugin', (error) => {
console.error(error);
process.exit(1);
});
}
} |
As karma is now deprecated and coming up on EOL, we are no longer planning on any significant enhancements to this project and are instead going to focus on security updates, stability, and a migration path forward as karma's lifecycle comes to an end. Thank you for supporting and using this project! |
If I use the
bail
option I get this errorand then nothing happens, but the process is still alive. After 5 minutes I stopped it.
If I run webpack only with
--bail
it works fine.maybe related to #49
The text was updated successfully, but these errors were encountered: