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(zone.js): remove abort listener on a signal when actual event is removed #55339

Closed
wants to merge 1 commit into from

Conversation

arturovt
Copy link
Contributor

This commit updates the implementation of the addEventListener patcher.

We're currently creating an abort event listener on the signal (when it's provided) and never remove it. The abort event listener creates a closure which captures task (tasks capture zones and other stuff too) and prevent task, zones and signals from being garbage collected.

We now store the function which removes the abort event listener when the actual event listener is being removed. The function is stored on task data since task data is already being used to store different types of information that's necessary to be shared between addEventListener and removeEventListener.

Closes #54739

@pullapprove pullapprove bot requested a review from JiaLiPassion April 14, 2024 21:01
Copy link
Contributor

@JiaLiPassion JiaLiPassion left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks.

@ngbot ngbot bot added this to the Backlog milestone Apr 15, 2024
…s removed

This commit updates the implementation of the `addEventListener` patcher.

We're currently creating an abort event listener on the signal (when it's provided)
and never remove it. The abort event listener creates a closure which captures `task`
(tasks capture zones and other stuff too) and prevent `task`, zones and signals from
being garbage collected.

We now store the function which removes the abort event listener when the actual event
listener is being removed. The function is stored on task data since task data is already
being used to store different types of information that's necessary to be shared between
`addEventListener` and `removeEventListener`.

Closes angular#54739
@AndrewKushnir AndrewKushnir added target: patch This PR is targeted for the next patch release action: global presubmit The PR is in need of a google3 global presubmit labels May 3, 2024
@AndrewKushnir
Copy link
Contributor

Presubmit (TGP).

@AndrewKushnir
Copy link
Contributor

Caretaker note: TGP is "green", this PR is ready for merge.

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: rc This PR is targeted for the next release-candidate and removed action: global presubmit The PR is in need of a google3 global presubmit target: patch This PR is targeted for the next patch release labels May 6, 2024
@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit a9460d0.

AndrewKushnir pushed a commit that referenced this pull request May 7, 2024
…s removed (#55339)

This commit updates the implementation of the `addEventListener` patcher.

We're currently creating an abort event listener on the signal (when it's provided)
and never remove it. The abort event listener creates a closure which captures `task`
(tasks capture zones and other stuff too) and prevent `task`, zones and signals from
being garbage collected.

We now store the function which removes the abort event listener when the actual event
listener is being removed. The function is stored on task data since task data is already
being used to store different types of information that's necessary to be shared between
`addEventListener` and `removeEventListener`.

Closes #54739

PR Close #55339
@arturovt arturovt deleted the fix/54739 branch May 7, 2024 15:09
@angular-automatic-lock-bot
Copy link

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 Jun 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: zones merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

addEventListener with AbortSignal option can cause memory leaks
4 participants