This repository was archived by the owner on Feb 17, 2026. It is now read-only.
fix(i18n): globalstateservice stateupdates memory leak#343
Open
Bowen7 wants to merge 2 commits intovmware-clarity:mainfrom
Open
fix(i18n): globalstateservice stateupdates memory leak#343Bowen7 wants to merge 2 commits intovmware-clarity:mainfrom
Bowen7 wants to merge 2 commits intovmware-clarity:mainfrom
Conversation
|
👋 @Bowen7,
Thank you, 🤖 Clarity Release Bot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Demo: https://stackblitz.com/edit/clarity-core-angularjs-yk53hdkf?file=src%2Findex.js
Continuously clicking the Show/Hide button, find that
GlobalStateService.stateUpdates.subscriptions.lengthis continuously increasing:And the detached

cds-alertDOM in the memory is also increasing:Affected components: which use
@i8n, such as: alert, password...Root Cause
core/projects/core/src/internal/decorators/i18n.ts
Line 61 in a93e9a6
__i18nSubis on theprotoOrDescriptornot the instance. Take alert as an example: all the alerts on the page will share the same__i18nSub, so if we remove all the alerts, only one__i18nSub(the newest one) will be unsubscribed. This causes the detached DOM to remain in memory.There is also an issue that is caused by
extends:Assume that
class Auses@i18n, andclass Balso uses@i18nwhile extending class A. In this case, an instance ofclass Awill have two subscriptions whenconnectedCallback, but__i18nSubonly saves the latest one. Therefore, only the latest subscription will be unsubscribed whendisconnectedCallback.So I added an if condition:
If we always use i18n as the name
@i18n() i18n, it's okay, or do we need to keep these two subscriptions and unsubscribe from both of them whendisconnectedCallback?Issue Number: #67
What is the new behavior?
Unsubscribe from its subscription when the element is removed
Does this PR introduce a breaking change?
Other information