diff --git a/templates/Angular2Spa/ClientApp/boot-server.ts b/templates/Angular2Spa/ClientApp/boot-server.ts index 0c4c3aa..a5ee086 100644 --- a/templates/Angular2Spa/ClientApp/boot-server.ts +++ b/templates/Angular2Spa/ClientApp/boot-server.ts @@ -8,21 +8,27 @@ enableProdMode(); const platform = platformNodeDynamic(); export default function (params: any) : Promise<{ html: string, globals?: any }> { - const requestZone = Zone.current.fork({ - name: 'angular-universal request', - properties: { - baseUrl: '/', - requestUrl: params.url, - originUrl: params.origin, - preboot: false, - // TODO: Render just the component instead of wrapping it inside an extra HTML document - // Waiting on https://github.com/angular/universal/issues/347 - document: '' - } - }); - - return requestZone.run>(() => platform.serializeModule(AppModule)) - .then(html => { - return { html: html }; + return new Promise((resolve, reject) => { + const requestZone = Zone.current.fork({ + name: 'angular-universal request', + properties: { + baseUrl: '/', + requestUrl: params.url, + originUrl: params.origin, + preboot: false, + // TODO: Render just the component instead of wrapping it inside an extra HTML document + // Waiting on https://github.com/angular/universal/issues/347 + document: '' + }, + onHandleError: (parentZone, currentZone, targetZone, error) => { + // If any error occurs while rendering the module, reject the whole operation + reject(error); + return true; + } }); + + return requestZone.run>(() => platform.serializeModule(AppModule)).then(html => { + resolve({ html: html }); + }, reject); + }); }