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

大兔子大兔子 提交于 2021-01-28 05:07:16

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/46305424/unhandled-promise-rejection-windowglobal-promise-has-been-overwritten

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!