-
Notifications
You must be signed in to change notification settings - Fork 27.1k
toSignal: remove cleanup callback from DestroyRef when Observable terminates #61511
Copy link
Copy link
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: rxjs interopstate: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
toSignal without manualCleanup: true adds a callback to DestroyRef to end the subscription when the injector is destroyed.
If the Observable terminates (error or complete) before the injector is destroyed, the callback is not removed from DestroyRef, leading to a memory leak.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version)
19.2.11 (also present in master)
Anything else?
In my application I have a long-lived component that repeatedly uses toSignal based on external input. Those Observables typically end before the component is destroyed. But I want the last remaining subscriptions to be cancelled automatically when the component is destroyed.
As a workaround I could use manualCleanup: true with takeUntilDestroyed() .
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: rxjs interopstate: has PR