Repository navigation
fix(core): destroy embedded views when creation fails - #72220
Closed
jipeng6036-del wants to merge 1 commit into
Closed
jipeng6036-del wants to merge 1 commit into
jipeng6036-del wants to merge 1 commit into
Conversation
Tear down partially created embedded views before rethrowing a render error. Skip cleanup entries that the failed instance did not register. Fixes angular#72210
Member
|
Thanks for investigating #72210 and putting this together! Calling
Closing this in favor of #72222, which addresses these cases as well. |
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.
PR Checklist
PR Type
What is the current behavior?
If a sibling throws while an embedded view is being created, the view is never attached to a container that could destroy it. Earlier siblings keep their destroy hooks and subscriptions alive across retries.
Fixes #72210
What is the new behavior?
Destroy the partially created view before rethrowing the render error. The cleanup loop skips entries that the failed instance did not reach, so teardown can still run when a previous instance registered more listeners on the same template.
Does this PR introduce a breaking change?
Other information
The regression test first renders a healthy view, then triggers an update error and retries with a constructor error. On the original code, the retry leaves one earlier sibling alive. With this change both siblings are destroyed and the boundary still reports the constructor error.
The new test failed on the original code. The full render3 Jasmine target passed with the fix (609 specs, 0 failures, 2 existing pending specs). Prettier passed for the changed files.
Thanks to @SkyZeroZx for the reproduction and for pointing out which destroy hooks were missing.