Skip to content

fix(upgrade): leak when angular1 destroys element#6460

Closed
andreialecu wants to merge 4 commits into
angular:masterfrom
andreialecu:patch-2
Closed

fix(upgrade): leak when angular1 destroys element#6460
andreialecu wants to merge 4 commits into
angular:masterfrom
andreialecu:patch-2

Conversation

@andreialecu
Copy link
Copy Markdown
Contributor

Fixes #6401

Not sure why this is bound to $remove, the proper event is $destroy according to https://docs.angularjs.org/api/ng/function/angular.element

@usernamealreadyis
Copy link
Copy Markdown

Fixes #6401 ?=140406f

@tbosch
Copy link
Copy Markdown
Contributor

tbosch commented Feb 1, 2016

Hi, thanks!
Could you create a test for this?

@tbosch tbosch added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Feb 1, 2016
@andreialecu
Copy link
Copy Markdown
Contributor Author

@tbosch: added test.

@texel
Copy link
Copy Markdown

texel commented Feb 20, 2016

This needs to be merged- without it, any angular1 app that uses angular2 components will never clean up those components.

@andreialecu
Copy link
Copy Markdown
Contributor Author

@tbosch: mind giving this another look?

@lacolaco
Copy link
Copy Markdown
Contributor

lacolaco commented Mar 4, 2016

@tbosch Please review. We need this fix seriously.

@andreialecu
Copy link
Copy Markdown
Contributor Author

9 betas and 2 months later still no feedback here.

Is there anything I need to change for it to get merged faster? It's absolutely critical for a few apps I've been working on.

angular1->2 upgraded apps simply can't function right without this fix - anything that uses an angular1 ng-if leaks resources like crazy.

And it's not just resources, for example I have some logic that shows a modal when a certain websocket event arrives, and there is no way to unsubscribe from it when the user navigates away. The ngOnDestroy event is never fired in the angular2 component.

Paging more people (sorry): @tbosch @vsavkin @IgorMinar


registerCleanup() {
this.element.bind('$remove', () => this.viewManager.destroyRootHostView(this.hostViewRef));
this.element.bind('$destroy', () => this.viewManager.destroyRootHostView(this.hostViewRef));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: .on() is supposed to be preferred with jQuery.
(Without jQuery, .bind() is just an alias to .on().)

@gkalpak
Copy link
Copy Markdown
Member

gkalpak commented Mar 13, 2016

FWIW, it LGTM 😃

@IgorMinar
Copy link
Copy Markdown
Contributor

@andreialecu sorry about the delay.. this should be out with the next beta.

@mary-poppins
Copy link
Copy Markdown

Merging PR #6460 on behalf of @alxhub to branch presubmit-alxhub-pr-6460.

@alxhub
Copy link
Copy Markdown
Member

alxhub commented Apr 6, 2016

@andreialecu This is merged now via #7935 (I squashed your commits into one). Thanks!

@alxhub alxhub closed this Apr 6, 2016
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: merge The PR is ready for merge by the caretaker cla: yes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(upgrade): leak: ngOnDestroy not called when angular1 destroys directive