-
Notifications
You must be signed in to change notification settings - Fork 407
fix(promise): can set native promise after loading zone.js #899
Conversation
d77ffd9
to
3e51741
Compare
This looks like a good idea. Let me know when it is ready. |
3e51741
to
d07a832
Compare
@mhevery , I have resolved the conflict and rebased, please review. And I also disable |
80dd75b
to
56aec97
Compare
This is great and will alleviate a huge pain for us. We have to load a variety of widgets from CDN built by different teams that all serve all sorts of Promise polyfills. Thank you for the fix! Looking forward to the next release of zone.js with this fixed |
Looks like the error has returned, I can't execute my angular universal server-side app, node throws me that error when I try it. (node:15488) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
/var/www/html/proyectoclase/server.js:3024
*/!function(e){var t=e.performance;functionn(e){t&&t.mark&&t.mark(e)}function r(e,n){t&&t.measure&&t.measure(e,n)}if(n("Zone"),e.Zone)throw new Error("Zone already loaded.");var i,o=function(){function t(e,t){this._properties=null,this._parent=e,this._name=t?t.name||"unnamed":"<root>",this._properties=t&&t.properties||{},this._zoneDelegate=new s(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==k.ZoneAwarePromise)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")},Object.defineProperty(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return O.zone},enumera
Error: listen EACCES http://https://wikos-inc.com/proyectoclase/
at Server.setupListenHandle [as _listen2] (net.js:1313:19)
at listenInCluster (net.js:1378:12)
at Server.listen (net.js:1477:5)
at Function._.listen (/var/www/html/proyectoclase/server.js:2900:4545)
at Object.<anonymous> (/var/www/html/proyectoclase/server.js:3077:2865)
at n (/var/www/html/proyectoclase/server.js:1:172)
at /var/www/html/proyectoclase/server.js:1:979
at Object.<anonymous> (/var/www/html/proyectoclase/server.js:1:990)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
Emitted 'error' event at:
at emitErrorNT (net.js:1357:8)
at e.invokeTask (/var/www/html/proyectoclase/server.js:3024:7685)
at t.runTask (/var/www/html/proyectoclase/server.js:3024:2865)
at t.invokeTask (/var/www/html/proyectoclase/server.js:3024:8799)
at o.useG.invoke (/var/www/html/proyectoclase/server.js:3024:8690)
at t.args.(anonymous function) (/var/www/html/proyectoclase/server.js:3077:831)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:746:11)
at startup (internal/bootstrap/node.js:238:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)
|
@Mystic-Ervo , some how the |
@JiaLiPassion oh, nice! ^^ |
fix #898, #891, #783
currently after loading
zone.js
, if we load some libraries which will overrideglobal Promise
,Zone.assertZonePatched
will throw error, andangular
will not started.Sometimes we use 3rd party libraries and hard to control the load orders. So we need a better way to handle this process.
in this PR.
patch
global.Promise
with a setter by using Object.defineProperty , so after loadingzone.js
, if a new Promise want to overrideglobal.Promise
, it will not update theglobal.Promise
, but update the underlyingNativePromise
, so the whole process will be:zone.js
,NativePromise
is Browser built in Promise.zone.js
, global.Promise isZoneAwarePromise
, global[symbolPromise] isNativePromise
.zone.js
, set other Promise, such ases6-promise
, global.Promise is stillZoneAwarePromise
, and global[symbolPromise] will be updated toes6-promise
.Zone.assertZonePatched will only throw error when user set this before loading
zone.js