From bb7d69def0551ba4902bad0f4d445c4d07f2221f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Polomsk=C3=BD?= Date: Tue, 25 Jul 2017 17:20:16 +0200 Subject: [PATCH] Fix exit code and ELIFECYCLE error Due to race condition (process.exit() called multiple times) sometimes process fails with error ELIFECYCLE. In that case process exits with exit code 0 but should exit with exit code 2. This change ensures that the race condition can not happened. --- bin/webpack.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/webpack.js b/bin/webpack.js index fe328474e1a..e2b9bf22e4c 100644 --- a/bin/webpack.js +++ b/bin/webpack.js @@ -350,16 +350,14 @@ function processOptions(options) { process.stdout.write(statsString + "\n"); } if(!options.watch && stats.hasErrors()) { - process.on("exit", function() { - process.exit(2); // eslint-disable-line - }); + process.exitCode = 2; } } if(firstOptions.watch || options.watch) { var watchOptions = firstOptions.watchOptions || firstOptions.watch || options.watch || {}; if(watchOptions.stdin) { process.stdin.on("end", function() { - process.exit(0); // eslint-disable-line + process.exit(); // eslint-disable-line }); process.stdin.resume(); }