Skip to content

Commit 449d178

Browse files
committed
catch error in runAsChild callback
1 parent 86a8bd9 commit 449d178

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/Compiler.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,21 @@ class Compiler {
545545
*/
546546
runAsChild(callback) {
547547
const startTime = Date.now();
548+
549+
const finalCallback = (err, entries, compilation) => {
550+
try {
551+
if (err) return callback(err);
552+
callback(null, entries, compilation);
553+
} catch (e) {
554+
const err = new WebpackError(
555+
`compiler.runAsChild callback error: ${e}`
556+
);
557+
this.parentCompilation.errors.push(err);
558+
}
559+
};
560+
548561
this.compile((err, compilation) => {
549-
if (err) return callback(err);
562+
if (err) return finalCallback(err);
550563

551564
this.parentCompilation.children.push(compilation);
552565
for (const { name, source, info } of compilation.getAssets()) {
@@ -561,7 +574,7 @@ class Compiler {
561574
compilation.startTime = startTime;
562575
compilation.endTime = Date.now();
563576

564-
return callback(null, entries, compilation);
577+
return finalCallback(null, entries, compilation);
565578
});
566579
}
567580

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy