Skip to content

bug(cdk/tree): Memory leak in CdkTreeNode #31454

Open
@AStrelkov

Description

@AStrelkov

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Next subscription is never unsubscribed in row 1398 of 'tree.ts':

this._tree
._getExpansionModel()
.changed.pipe(
map(() => this.isExpanded),
distinctUntilChanged(),
)
.subscribe(() => this._changeDetectorRef.markForCheck());

Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

Expected Behavior

Unsubscribe this subscription using pipe(takeUntilDestroy()) or in ngOnDestroy() life hook.

Actual Behavior

Subscription never unsubscribed.

Environment

  • Angular: 19, 20
  • CDK/Material: CDK
  • Browser(s): Chrome, Edge
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/tree

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions