From b82e70e192f22a895ad676dccd6228f33af7477f Mon Sep 17 00:00:00 2001 From: SteveSandersonMS Date: Thu, 30 Jun 2016 16:56:48 +0100 Subject: [PATCH] Fix for prerendering hanging if webpack compilation fails --- .../npm/aspnet-webpack/package.json | 2 +- .../npm/aspnet-webpack/src/LoadViaWebpack.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json index b919303..bfcf501 100644 --- a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json +++ b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/package.json @@ -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": { diff --git a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/LoadViaWebpack.ts b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/LoadViaWebpack.ts index a084457..93b4b4c 100644 --- a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/LoadViaWebpack.ts +++ b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/LoadViaWebpack.ts @@ -52,7 +52,7 @@ function loadViaWebpackNoCache(webpackConfigPath: string, modulePath: string) webpackConfig.plugins = webpackConfig.plugins.filter(plugin => { return !(plugin instanceof webpack.optimize.CommonsChunkPlugin); }); - + // The typical use case for DllReferencePlugin is for referencing vendor modules. In a Node // environment, it doesn't make sense to load them from a DLL bundle, nor would that even // work, because then you'd get different module instances depending on whether a module @@ -78,9 +78,14 @@ function loadViaWebpackNoCache(webpackConfigPath: string, modulePath: string) if (err) { reject(err); } else { - const fileContent = compiler.outputFileSystem.readFileSync('/webpack-output.js', 'utf8'); - const moduleInstance = requireFromString(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(fileContent); + resolve(moduleInstance); + } catch(ex) { + reject(ex); + } } }); });