Repository: angular
Issue: Uncaught Error while prerendering during ng build --prod
Labels: type: bug/fix,freq1: low,area: core,state: needs more investigation,P3

# 🐞 bug report

### Affected Package
\node_modules\zone.js\dist\zone-node.js:814:31

### Description
During the build of my application I get an “Uncaught in promise Error” thrown by zone-node.js:831. My application has just one Promise with a catch block. So, this Uncaught error should not be thrown. 
The "rejected" status of the promise comes from a http request which fails. 


## 🔬 Minimal Reproduction

https://github.com/kemler89/uncaught-error

Short summary:
The project contains a service (AppConfigService) which loads a Json-Config file as runtime configuration file of the application. The load functionality will be handled in the loadAppConfig method which returns a promise – because the APP_INITIALIZER only supports promises as of now. For the error handling the promise has a catch block. To load the runtime configuration before the application has started the AppConfigService will be executed when the application gets initialized. This will be handled in app-config.module.ts

Step to reproduce:
just run "ng build"

The console will show the following error:
ERROR { Error: Uncaught (in promise): Error

expected behavior would be that no error occurs because the error will be caught in app-config.service.ts

To avoid the error you have to run "ng serve" and change the path to the json file from './assets/data/appConfig.json' to 'http://localhost:4200/assets/data/appConfig.json' in app.module.ts

now "ng build" will run without the ERROR.


## 🔥 Exception or Error
ERROR { Error: Uncaught (in promise): Error
    at resolvePromise (P:\Projekte\uncaught-error\node_modules\zone.js\dist\zone-node.js:831:31)
    at P:\Projekte\uncaught-error\node_modules\zone.js\dist\zone-node.js:741:17
    at SafeSubscriber._error (P:\Projekte\uncaught-error\node_modules\rxjs\internal\Observable.js:99:89)
    at SafeSubscriber.__tryOrUnsub (P:\Projekte\uncaught-error\node_modules\rxjs\internal\Subscriber.js:205:16)
    at SafeSubscriber.error (P:\Projekte\uncaught-error\node_modules\rxjs\internal\Subscriber.js:156:26)
    at Subscriber._error (P:\Projekte\uncaught-error\node_modules\rxjs\internal\Subscriber.js:92:26)
    at Subscriber.error (P:\Projekte\uncaught-error\node_modules\rxjs\internal\Subscriber.js:72:18)
    at MapSubscriber.Subscriber._error (P:\Projekte\uncaught-error\node_modules\rxjs\internal\Subscriber.js:92:26)
    at MapSubscriber.Subscriber.error (P:\Projekte\uncaught-error\node_modules\rxjs\internal\Subscriber.js:72:18)
    at FilterSubscriber.Subscriber._error (P:\Projekte\uncaught-error\node_modules\rxjs\internal\Subscriber.js:92:26)
    at FilterSubscriber.Subscriber.error (P:\Projekte\uncaught-error\node_modules\rxjs\internal\Subscriber.js:72:18)
    at MergeMapSubscriber.OuterSubscriber.notifyError (P:\Projekte\uncaught-error\node_modules\rxjs\internal\OuterSubscriber.js:26:26)
    at InnerSubscriber._error (P:\Projekte\uncaught-error\node_modules\rxjs\internal\InnerSubscriber.js:31:21)
    at InnerSubscriber.Subscriber.error (P:\Projekte\uncaught-error\node_modules\rxjs\internal\Subscriber.js:72:18)
    at ZoneTask.onComplete [as callback] (P:\Projekte\uncaught-error\node_modules\@angular\platform-server\bundles\platform-server.umd.js:379:34)
    at ZoneDelegate.invokeTask (P:\Projekte\uncaught-error\node_modules\zone.js\dist\zone-node.js:423:31)
  rejection: Error,




## 🌍  Your Environment

**Angular Version:**
7.2.15