fix(core): prevent destroyed views from being detached#66726
Open
edusperoni wants to merge 1 commit intoangular:mainfrom
Open
fix(core): prevent destroyed views from being detached#66726edusperoni wants to merge 1 commit intoangular:mainfrom
edusperoni wants to merge 1 commit intoangular:mainfrom
Conversation
JeanMeche
reviewed
Jan 23, 2026
58f19b2 to
26677af
Compare
Member
|
The change seems to be consistenly breaking as its shown by our local tests and ones in Google's code base. |
Contributor
Author
|
@JeanMeche can you clarify where it breaks? It seems like the available tests all pass and I believe the behavior is undesired right now (breaking the destroy flow) |
A destroyed view will always remove itself after destruction, so it should never be allowed to be detached before that as doing so will break the destroy chain
26677af to
a2367a1
Compare
Member
|
It breaks some devtools and angular.dev tests. The timeouts are likely to be tied to some tests stuck on a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A destroyed view will always remove itself after destruction, so it should never be allowed to be detached before that as doing so will break the destroy chain
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
When destroying a component, one might inadvertently try to remove the element from its ViewContainerRef. Doing so will break the destroy lifecycle hook as angular is unable to go back up the destroy tree.
Issue Number: N/A
What is the new behavior?
Attempting to detach/remove a node that's destroyed will fail to do so.
Does this PR introduce a breaking change?
Other information
I hit this when playing with CDK portals and doing:
portalOutlet will remove the item from the ViewContainerRef, which would stop destroying components with no error.
Maybe we could instead throw an error with a ngDevMode check instead?