Skip to content
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): incorrect error reported when trying to re-create view which had an error during creation #43005

Closed

Conversation

@crisbeto
Copy link
Member

@crisbeto crisbeto commented Jul 31, 2021

Currently if a view throws an error during creation mode, we mark it as incompleteFirstPass so that we can try to recover later. The recovery is only possible inside component views.

The problem is that when this was introduced, I forgot to flip the firstCreatePass when an error is thrown which meant that calling renderView on the same component again is allowed. It will eventually hit an assertion which can be confusing for the end user. This issue only manifests itself when rendering views "manually" through ViewContainerRef (e.g. using NgIf).

These changes flip the firstCreatePass back to false on errors so that trying to re-render the same view will throw an error which is consistent to the one that broke the view during creation.

Fixes #41383.

@google-cla google-cla bot added the cla: yes label Jul 31, 2021
@crisbeto crisbeto force-pushed the 41383/incomplete-first-pass-error branch from 1096454 to fc546dd Jul 31, 2021
@@ -30,7 +30,7 @@
"master": {
"uncompressed": {
"runtime-es2015": 1190,
"main-es2015": 136546,
"main-es2015": 137055,
Copy link
Member Author

@crisbeto crisbeto Jul 31, 2021

There's only one line that affects the runtime in this PR so I doubt that the size difference comes from it.

@crisbeto crisbeto marked this pull request as ready for review Jul 31, 2021
@pullapprove pullapprove bot requested a review from jessicajaniuk Jul 31, 2021
@ngbot ngbot bot added this to the Backlog milestone Jul 31, 2021
@ngbot ngbot bot added this to the Backlog milestone Jul 31, 2021
@ngbot ngbot bot added this to the Backlog milestone Jul 31, 2021
@AndrewKushnir AndrewKushnir requested review from AndrewKushnir and removed request for jessicajaniuk Aug 2, 2021
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

@crisbeto thanks for the fix 👍

Reviewed-for: fw-core, size-tracking

fixture.detectChanges();
}).toThrowError(/No provider for DoesNotExist/);

expect(() => {
Copy link
Contributor

@AndrewKushnir AndrewKushnir Aug 2, 2021

Nit: I'd propose adding a quick comment here to describe why we do the second check (which looks the same as the previous one), i.e. that it's intentional.

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Aug 2, 2021

atscott
atscott approved these changes Aug 2, 2021
Copy link
Contributor

@atscott atscott left a comment

reviewed-for: size-tracking

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Aug 2, 2021

FYI, the presubmit went well for the changes in this PR, the changes were reviewed/approved, adding this PR to the merge queue.

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Aug 2, 2021

Ah, sorry, I think there is a minor comment related to the tests that would be great to address, so I'm adding the "cleanup" label for now. Another presubmit should not be required since additional changes would be in tests only.

crisbeto added 2 commits Aug 3, 2021
…ch had an error during creation

Currently if a view throws an error during creation mode, we mark it as `incompleteFirstPass` so that we can try to recover later. The recovery is only possible inside component views.

The problem is that when this was introduced, I forgot to flip the `firstCreatePass` when an error is thrown which meant that calling `renderView` on the same component again is allowed. It will eventually hit an assertion which can be confusing for the end user. This issue only manifests itself when rendering views "manually" through `ViewContainerRef` (e.g. using `NgIf`).

These changes flip the `firstCreatePass` back to false on errors so that trying to re-render the same view will throw an error which is consistent to the one that broke the view during creation.

Fixes angular#41383.
@crisbeto crisbeto force-pushed the 41383/incomplete-first-pass-error branch from fc546dd to 19a1e13 Aug 3, 2021
@crisbeto
Copy link
Member Author

@crisbeto crisbeto commented Aug 3, 2021

The feedback has been addressed.

atscott added a commit that referenced this issue Aug 4, 2021
…ch had an error during creation (#43005)

Currently if a view throws an error during creation mode, we mark it as `incompleteFirstPass` so that we can try to recover later. The recovery is only possible inside component views.

The problem is that when this was introduced, I forgot to flip the `firstCreatePass` when an error is thrown which meant that calling `renderView` on the same component again is allowed. It will eventually hit an assertion which can be confusing for the end user. This issue only manifests itself when rendering views "manually" through `ViewContainerRef` (e.g. using `NgIf`).

These changes flip the `firstCreatePass` back to false on errors so that trying to re-render the same view will throw an error which is consistent to the one that broke the view during creation.

Fixes #41383.

PR Close #43005
@atscott atscott closed this in 8628826 Aug 4, 2021
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Sep 4, 2021

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 4, 2021
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 16, 2021
…ch had an error during creation (angular#43005)

Currently if a view throws an error during creation mode, we mark it as `incompleteFirstPass` so that we can try to recover later. The recovery is only possible inside component views.

The problem is that when this was introduced, I forgot to flip the `firstCreatePass` when an error is thrown which meant that calling `renderView` on the same component again is allowed. It will eventually hit an assertion which can be confusing for the end user. This issue only manifests itself when rendering views "manually" through `ViewContainerRef` (e.g. using `NgIf`).

These changes flip the `firstCreatePass` back to false on errors so that trying to re-render the same view will throw an error which is consistent to the one that broke the view during creation.

Fixes angular#41383.

PR Close angular#43005
TeriGlover added a commit to TeriGlover/angular that referenced this issue Sep 22, 2021
…ch had an error during creation (angular#43005)

Currently if a view throws an error during creation mode, we mark it as `incompleteFirstPass` so that we can try to recover later. The recovery is only possible inside component views.

The problem is that when this was introduced, I forgot to flip the `firstCreatePass` when an error is thrown which meant that calling `renderView` on the same component again is allowed. It will eventually hit an assertion which can be confusing for the end user. This issue only manifests itself when rendering views "manually" through `ViewContainerRef` (e.g. using `NgIf`).

These changes flip the `firstCreatePass` back to false on errors so that trying to re-render the same view will throw an error which is consistent to the one that broke the view during creation.

Fixes angular#41383.

PR Close angular#43005
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants