Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
I was trying to implement a Registry Pattern with Angular Services and Signals and leaked some objects via the signals dependency tracking in an unexpected way. The stackblitz link below has more details but the gist of it is:
- I have a root provided service that performs some aggregation logic in a computed over a set of Signals that are registered with it by component scoped services.
- When the component scoped services are destroyed they unregister their signal.
- If the aggregation computed has run but now has no consumers, it will hold onto a reference to the destroyed component scoped service via the dependency tracking of the aggregate computed.
The odd thing I noticed is that if the registered Signal is created with signal() then there is no leak. But if the registered signal is a computed() then there is a leak. I expected both to leak or neither to leak.
I understand that normally a computed's dependencies are not recalculated if it's not being read but would it make sense for dependencies to be recalculated when one is being destroyed? Or when there are no readers?
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-k2tnpvcd?file=src%2Fmain.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version)
Anything else?
No response
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
I was trying to implement a Registry Pattern with Angular Services and Signals and leaked some objects via the signals dependency tracking in an unexpected way. The stackblitz link below has more details but the gist of it is:
The odd thing I noticed is that if the registered Signal is created with signal() then there is no leak. But if the registered signal is a computed() then there is a leak. I expected both to leak or neither to leak.
I understand that normally a computed's dependencies are not recalculated if it's not being read but would it make sense for dependencies to be recalculated when one is being destroyed? Or when there are no readers?
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-k2tnpvcd?file=src%2Fmain.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version)Anything else?
No response