Fix for prerendering hanging if webpack compilation fails

This commit is contained in:
SteveSandersonMS
2016-06-30 16:56:48 +01:00
parent 44bd5f195e
commit b82e70e192
2 changed files with 10 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "aspnet-webpack",
"version": "1.0.3",
"version": "1.0.4",
"description": "Helpers for using Webpack in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
"main": "index.js",
"scripts": {

View File

@@ -78,9 +78,14 @@ function loadViaWebpackNoCache<T>(webpackConfigPath: string, modulePath: string)
if (err) {
reject(err);
} else {
const fileContent = compiler.outputFileSystem.readFileSync('/webpack-output.js', 'utf8');
const moduleInstance = requireFromString<T>(fileContent);
resolve(moduleInstance);
// We're in a callback, so need an explicit try/catch to propagate any errors up the promise chain
try {
const fileContent = compiler.outputFileSystem.readFileSync('/webpack-output.js', 'utf8');
const moduleInstance = requireFromString<T>(fileContent);
resolve(moduleInstance);
} catch(ex) {
reject(ex);
}
}
});
});