karma-webpack: bail option does not exit the process

If I use the bail option I get this error

Hash: 8344a6c0a9b3c44a5636
Version: webpack 1.10.3
Time: 27501ms

ERROR in ./lib/forgot-password/client/view.coffee
Module not found: Error: Cannot resolve module 'component-eemitter' in /home/vagrant/lib/forgot-password/client
 @ ./lib/forgot-password/client/view.coffee 7:10-39
Hash: 8344a6c0a9b3c44a5636
Version: webpack 1.10.3
Time: 477ms

ERROR in ./lib/forgot-password/client/view.coffee
Module not found: Error: Cannot resolve module 'component-eemitter' in /home/vagrant/lib/forgot-password/client
 @ ./lib/forgot-password/client/view.coffee 7:10-39

and 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

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 31 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@Ivaylo-Lafchiev I’ve been using this plugin lately:

class ExitOnErrorWebpackPlugin {
  apply(compiler) {
    compiler.hooks.done.tap("ExitOnErrorWebpackPlugin", stats => {
      if (stats && stats.hasErrors()) {
        stats.toJson().errors.forEach(err => {
          console.error(err);
        });
        process.exit(1);
      }
    });
  }
}

Hope it helps.

👍 Facing this issue as well 😕

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.

Workarounds aside, we should be respecting the bail option inside the loader no?

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?

I’ve moved this into the org maintainers priority list. One of us, most likely me will get this sorted and out in 2.0.4

@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.

I’ve prepared a minimal repo where you can reproduce the issue.

https://github.com/ertrzyiks/karma-webpack-failed-compilation-example

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.