Unhandled Promise rejection: `(window|global).Promise` has been overwritten

6.3k views Asked by At

My polyfills.ts file contains:

import 'core-js/es6';
import 'core-js/es7/reflect';
require('zone.js/dist/zone');

Now I am frequently (but not always) getting thiserror:

Unhandled Promise rejection: Zone.js has detected that ZoneAwarePromise (window|global).Promise has been overwritten. Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded.

How can I fix this?

2

There are 2 answers

0
jiali passion On BEST ANSWER

this issue have been fixed by https://github.com/angular/zone.js/pull/899, in the next version of zone.js(0.8.19), the error will gone.

0
basarat On

How can I fix this?

The code you presented is fine, i.e. the following is the correct order:

import 'core-js/es6';
import 'core-js/es7/reflect';
require('zone.js/dist/zone');

Now I am frequently (but not always)

You are probably importing some module sometimes that does it in the wrong order.