Skip to content
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

fix(async pipe): prevent firing $digest after scope is destroyed. #220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SpeedShifter
Copy link

Issue:
async pipe could trigger digest after scope was destroyed.
It could result in memory leak, because digest will trigger async pipe (like a filter), making it to subscribe observable in already destroyed scope (and $destroy won't happen again).
The source of the problem for async pipe is _markForCheck method, that sets timeout, and triggers $digest without checking if scope is destroyed.
Solution: track timeouts and clean them while _dispose and before setting new timeout.

For test, set of async-destroy components were created. Clicking 'start' button dispatches change in Subject imitating application state. If 'Memory leak' (when digest called after scope being destroyed) happened, alert message will be shown. To test fail scenario comment clearTimeout lines if async pipe.
The key point is "middle" async-destroy-container component that on $destroy triggers synchronous change of Subject. Thats a scenario when component on destroy want to change the state of application.

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

Successfully merging this pull request may close these issues.

2 participants