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(cds-icon): fix globalstateservice memory leak #80

Merged

Conversation

ashleyryan
Copy link
Contributor

ensure the component is connected before subscribing to the globalstateservice

Fixes #61

Signed-off-by: Ashley Ryan asryan@vmware.com

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • If applicable, have a visual design approval

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • clarity.design website / infrastructure changes
  • Other... Please describe:

What is the current behavior?

When an element is immediately removed from the DOM, firstUpdated can be called after disconnectedCallback, resulting in an event listener created that never gets removed.

https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected

https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks

Issue Number: #61

What is the new behavior?

Added a check that the component is connected before creating the event listener

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

ensure the component is connected before subscribing to the globalstateservice

Fixes vmware-clarity#61

Signed-off-by: Ashley Ryan <asryan@vmware.com>
@github-actions
Copy link

github-actions bot commented May 24, 2022

👋 @ashleyryan,

  • 🙏 The Clarity team thanks you for opening a pull request
  • 🎉 The build for this PR has succeeded
  • 🔍 The PR is now ready for review
  • 🍿 In the meantime, checkout out a preview of this PR
  • 🖐 You can always follow up here. If you're a VMware employee, you can also reach us on our internal #clarity-support Slack channel

Thank you,

🤖 Clarity Release Bot

div.appendChild(icon);
icon.remove();

await new Promise(resolve => setTimeout(resolve, 0));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is rough, but I don't have a web component to wait on since I'm explicitly removing it immediately above.

@ashleyryan ashleyryan merged commit df13775 into vmware-clarity:main May 26, 2022
@ashleyryan ashleyryan deleted the asryan/cds-icon-memory-leak branch May 26, 2022 19:54
@github-actions
Copy link

🎉 This PR is included in version 6.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed PRs after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cds-icon causes memory leak and slow Angular v13 unit tests
4 participants