New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Losing zone in RxJS and fetch #31749
Comments
I have the same issue with observables (RxJS). |
What do you mean by "subsequent functions are not called"? Everything called in my case except these calls are not in the angular zone except for the very first operator. |
My issue was fixed by this commit angular/zone.js@c70f011. (0.6.10) does it fix yours ? |
No, didn't fix it. |
This is how I got it working - with 2 hacks:
|
I narrowed it down to a conflict with systemjs' system-polyfills.js (required by Angular2) The code in the attached file works as expected but enabling system-polyfills.js breaks it. |
BTW trying to run Angular2's "Hello World" without system-polyfills.js in Chrome 50 (which has native Promises) results in this error:
|
It seems that the issue still exists in More details are available in the following topic. Relevant source code: // Code that breaks Angular change detection:
nearbySearch(request: { location: any, radius: string, types: string[] }) {
return Observable.create(observer => {
if (this._places) {
this._places.nearbySearch(request, (result, status) => {
if (status == google.maps.places.PlacesServiceStatus.OK) {
observer.next(result);
observer.complete();
}
});
}
});
}
// Code that works fine:
test() {
return Observable.create(observer => {
let result = [{place_id: 1}, {place_id: 2}, {place_id: 3}];
setTimeout(() => {
observer.next(result);
observer.complete();
}, 2000);
});
}
onGetNear() {
this.nearbySearch({ /* ... */ }).subscribe(res => {
// The following logs 'root' instead of 'Angular'.
console.log(Zone.current.name);
// The view doesn't get updated:
this.places = res;
});
}
onGetTest() {
this.test().subscribe(res => {
// The following logs 'Angular'.
console.log(Zone.current.name);
// Updates the view as expected:
this.places = res;
});
} |
Looks like the problem has been fixed in the current version of Angular (angular2@2.0.0-beta.17, systemjs@0.19.27, zone.js@0.6.12), it no longer requires system-polyfills.js. |
I still have the RangeError issue running angular2 beta 17, systemjs@0.19.25 and zone.js@0.6.12. The weird thing is, it was working fine just yesterday. |
Seems like this issue might be the same issue #357 i'm experiencing. I removed system-polyfills.js from the files being loaded but i'm still having the RangeError. |
This happens when 2 copies of zone running in the same place. Before was system-polyfill. I run into the same issue when including zone.js in the same time. When 2 zone both monitor all promise calls, they will bounce off each other and causing stack overflow. angular-polyfill always contains ng's own zone implementation. zone.js shouldn't be loaded separately. |
I'll leave my experience here. When upgrading to rc-1, I forgot to include |
Experiencing this issue with angular-universal. My code looks similar to the following: fetchApi() {
console.log(Zone.current._name);
this._http.get('/url')
.map((value) => {
console.log(Zone.current._name);
})
.toPromise()
.then((response) => {
console.log(Zone.current._name);
});
} I'm getting: console output |
Got bitten by this as well. |
I appear to be having the same issue, also using an API that returns a promise within Angular (Atlassian connect library - .request returns a promise). ngFors and bindings, etc are not being updated. Only after a click in the relevant area. |
@siegenthalerroger , could you provide a reproduce repo? |
https://github.com/siegenthalerroger/zonejsissue/ Should do the trick. You'll have to run it within an Atlassian developer instance to see the effect of the AP object though. The whole thing is a bit of a mess because it's part of a larger project. The issue is in the app.component.ts file: |
Now we have a patch for |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
For my angular 2 project I created a service that uploads files and I use fetch API there and RxJS. But it doesn't keep angular zone, here:
the output is:
This shouldn't be like it I think. As a result, component's view doesn't ever get updated.
Also, once zone is lost it never gets back to 'angular'. So I see angular only the first time it runs.
zone: 0.6.8.
The text was updated successfully, but these errors were encountered: