-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: upgradeIssues related to AngularJS → Angular upgrade APIsIssues related to AngularJS → Angular upgrade APIs
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Destroying a downgraded component with @Output leaks a rxjs subscription
Steps to reproduce:
- You need an Angular component with an
@Output - Downgrade to use it in an AngularJS component
- Create & destroy the downgraded component, e.g. by routing to a page that contains it and then routing away
private subscribeToOutput(output: PropertyBinding, expr: string, isAssignment: boolean = false) {
const getter = this.$parse(expr);
const setter = getter.assign;
if (isAssignment && !setter) {
throw new Error(`Expression '${expr}' is not assignable!`);
}
const emitter = this.component[output.prop] as EventEmitter<any>;
if (emitter) {
emitter.subscribe({ <------------- this subscription is never unsubscribed from
next: isAssignment ? (v: any) => setter!(this.scope, v) :
(v: any) => getter(this.scope, {'$event': v})
});
} else {
throw new Error(`Missing emitter '${output.prop}' on component '${
getTypeName(this.componentFactory.componentType)}'!`);
}
}The subscription leak might be garbage collectable depending on how the @Output observable is defined, our leak check tooling cannot test that programatically. In any case a user could have defined the @Output to be a long-lived observable, in which this is a genuine leak.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 14.2.9
Node: 16.15.0
Package Manager: npm 8.5.5
OS: linux x64
Angular: 14.2.10
... animations, common, compiler, compiler-cli, core, elements
... forms, language-service, localize, platform-browser
... platform-browser-dynamic, router, upgrade
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1402.9
@angular-devkit/build-angular 14.2.9
@angular-devkit/core 14.2.9
@angular-devkit/schematics 13.3.5
@angular/cdk 14.2.7
@angular/cli 14.2.9
@angular/material 14.2.7
@schematics/angular 14.2.9
ng-packagr 14.1.0
rxjs 6.6.7
typescript 4.7.4
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: upgradeIssues related to AngularJS → Angular upgrade APIsIssues related to AngularJS → Angular upgrade APIs