Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Zone.js hangs on Meteor env #946

Closed
ardatan opened this issue Nov 1, 2017 · 5 comments · Fixed by #1041
Closed

Zone.js hangs on Meteor env #946

ardatan opened this issue Nov 1, 2017 · 5 comments · Fixed by #1041

Comments

@ardatan
Copy link

ardatan commented Nov 1, 2017

Due to Meteor's restriction of 'patchThen' issue, it was fixed to force patching by change property of writable to true.
#851
In Meteor 1.6, 'then' should not patch in case of writable : false, because it causes hanging.
I think fix should be like

var prop = Object.getOwnPropertyDescriptor(Ctor.prototype, 'then');
if (prop && prop.writable !== false) {
     Ctor.prototype.then = function (onResolve, onReject) {
       var _this = this;
        var wrapped = new ZoneAwarePromise(function (resolve, reject) {
            originalThen.call(_this, resolve, reject);
        });
        return wrapped.then(onResolve, onReject);
     };
}

This fix is important for new version of Angular Meteor. I hope you will be interested in. Thanks.

@ardatan ardatan changed the title Node Zone.js hangs on Meteor env Nov 1, 2017
@JiaLiPassion
Copy link
Collaborator

@ardatan , could you describe a little more about hanging, you mean with #851, if the writable is changed to true, it will hang because of zone patched then?

@ardatan
Copy link
Author

ardatan commented Nov 1, 2017

Meteor uses Fibers by patching Promise.then as well, then change 'writable' false. After that, zone.js patches Promise( by forcing to make it writable ).
Application freezes in case of use of Promise.
However, if zone.js doesn't patch Promise.then, it works well.

@JiaLiPassion
Copy link
Collaborator

@ardatan , I am not familiar with Meteor, if zone.js doesn't patch Promise.then, Promise will not trigger any ZoneSpec callback, so angular will not work as expected (such as change detection).

@ardatan
Copy link
Author

ardatan commented Nov 1, 2017

Angular already calls ZoneAwarePromise in application. Btw, this is only for server-side rendering, and it works correctly if we do not overwrite 'prototype.then'.
So it will be safe to change code like I mentioned before in my opinion.

@apatryda-instapage
Copy link

I can confirm that the patch sugested by @ardatan fixes meteor backend issues with zone.js

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants