Skip to content

Commit 3259c62

Browse files
authored
Merge pull request webpack#8409 from hulkish/async-queue-dont-swallow-errors
fix: report existing errors before async queue stop error
2 parents 1085bda + 9181283 commit 3259c62

10 files changed

+703
-352
lines changed

lib/Compilation.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const ModuleTemplate = require("./ModuleTemplate");
3939
const RuntimeGlobals = require("./RuntimeGlobals");
4040
const RuntimeTemplate = require("./RuntimeTemplate");
4141
const Stats = require("./Stats");
42+
const WebpackError = require("./WebpackError");
4243
const StatsFactory = require("./stats/StatsFactory");
4344
const StatsPrinter = require("./stats/StatsPrinter");
4445
const AsyncQueue = require("./util/AsyncQueue");
@@ -1046,15 +1047,19 @@ class Compilation {
10461047
dependency === null ||
10471048
!dependency.constructor
10481049
) {
1049-
throw new Error("Parameter 'dependency' must be a Dependency");
1050+
return callback(
1051+
new WebpackError("Parameter 'dependency' must be a Dependency")
1052+
);
10501053
}
10511054
const Dep = /** @type {DepConstructor} */ (dependency.constructor);
10521055
const moduleFactory = this.dependencyFactories.get(Dep);
10531056
if (!moduleFactory) {
1054-
throw new Error(
1055-
`No dependency factory available for this dependency type: ${
1056-
dependency.constructor.name
1057-
}`
1057+
return callback(
1058+
new WebpackError(
1059+
`No dependency factory available for this dependency type: ${
1060+
dependency.constructor.name
1061+
}`
1062+
)
10581063
);
10591064
}
10601065

@@ -1066,14 +1071,15 @@ class Compilation {
10661071
context
10671072
},
10681073
err => {
1069-
if (this.bail) {
1074+
if (err && this.bail) {
1075+
callback(err);
10701076
this.buildQueue.stop();
10711077
this.rebuildQueue.stop();
10721078
this.processDependenciesQueue.stop();
10731079
this.factorizeQueue.stop();
1074-
return callback(err);
1080+
} else {
1081+
callback();
10751082
}
1076-
return callback();
10771083
}
10781084
);
10791085
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"events": "^3.0.0",
2020
"json-parse-better-errors": "^1.0.2",
2121
"json-stable-stringify": "^1.0.1",
22-
"loader-runner": "^2.3.0",
22+
"loader-runner": "3.0.0",
2323
"loader-utils": "^1.1.0",
2424
"memory-fs": "~0.4.1",
2525
"micromatch": "^3.1.8",
@@ -61,6 +61,7 @@
6161
"lint-staged": "^8.0.4",
6262
"lodash": "^4.17.4",
6363
"prettier": "^1.14.3",
64+
"pretty-format": "24.0.0-alpha.1",
6465
"pug": "^2.0.3",
6566
"pug-loader": "^2.4.0",
6667
"raw-loader": "~0.5.0",

0 commit comments

Comments
 (0)