-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: ion-router-outlet triggers ngOnDestroy outside the Angular zone #22571
Comments
Thanks for the issue. Did you push your changes that show this bug happening? I cloned your repository, but it just looks like a blank Ionic starter app. |
Oups! Sorry for that. It should be ok now. |
@liamdebeasi any news on this? It's been 4 months already and this is a pretty big issue. |
Yup, I just got bit by this bug once again, even though I know about it... |
Hello everyone! I have an open PR to address this problem. In the interim, you can test with this dev build:
Thanks! |
While I'm no longer working on an ionic project, I just looked at your PR and it looks like it should address the issue. Fantastic! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Bug Report
Ionic version:
[ ] 4.x
[x] 5.x
Current behavior:
In an ionic angular application using the ion-router-outlet, navigating away from a page in a way that would trigger the ngOnDestroy lifecycle method on the page component will cause the method to be called outside of the angular zone.
This causes issues when using ngOnDestroy to unsubscribe from observables which have finalize clauses that require change detection. For instance, dispatching an NgRx action in a finalize clause will cause an error in such scenario unless it is wrapped with
ngZone.run()
.Expected behavior:
The standard angular behavior is to run all lifecycle methods inside the angular zone. Swapping the ion-router-outlet for a angular router-outlet fixes this issue.
Steps to reproduce:
Related code:
See this repository for a repro project: https://github.com/imadh/ionic-router-outside-angular-zone
Simply navigate between the "hello" and "bye" pages multiple times to trigger the ngOnDestroy call. A console log will indicate if the method is called in the right zone.
Other information:
Ionic info:
The text was updated successfully, but these errors were encountered: