-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): onDestroy should be registered only on valid DestroyRef #49804
fix(core): onDestroy should be registered only on valid DestroyRef #49804
Conversation
de10cc4
to
95d1754
Compare
@pkozlowski-opensource shouldn't we at least log a warning when not in dev mode? I think that users will prefer a warning log message to a potential leak. |
It might happen that the lifecycle scope represented by DestroyRef becomes invalid before an onDestroy hook is registered (ex. injector or component instance got destroyed). In such cases registration of the onDestroy hooks should no longer be possible. Fixes angular#49658
95d1754
to
f975de0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed-for: public-api
FYI, I've also pushed a fixup commit with the golden file update to include a new error code. There were no functional changes in the fixup commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api
Caretaker: This is ready for merge. TGP was green. |
This PR was merged into the repository by commit 2c22e6f. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
It might happen that the lifecycle scope represented by DestroyRef becomes invalid before an onDestroy hook is registered (ex. injector or component instance got destroyed). In such cases registration of the onDestroy hooks should no longer be possible.
Fixes #49658