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): attempt to recover from user errors during creation #36381

Closed
wants to merge 2 commits into from

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Apr 1, 2020

If there's an error during the first creation pass of a TView, the data structure may be corrupted which will cause framework assertion failures downstream which can mask the user's error. These changes add a new flag to the TView that indicates whether the first creation pass was successful, and if it wasn't try re-create the TView.

Fixes #31221.

@crisbeto crisbeto force-pushed the FW-1974/creation-error-mask branch from e10a3b5 to 526ff89 Compare April 1, 2020 19:46
@crisbeto crisbeto marked this pull request as ready for review April 1, 2020 20:26
@crisbeto crisbeto added area: core Issues related to the framework runtime action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release type: bug/fix labels Apr 1, 2020
@ngbot ngbot bot modified the milestone: needsTriage Apr 1, 2020
Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - but only for the unrelated size change

integration/_payload-limits.json Outdated Show resolved Hide resolved
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this problem and creating a test case for it (which was tricky)! 👍

The changes LGTM (with a couple nits), but I think it'd be great if @pkozlowski-opensource can have a look at this change as well, so I'm adding him as a reviewer to this PR.

Thank you.

packages/core/test/acceptance/view_insertion_spec.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions/shared.ts Outdated Show resolved Hide resolved
@crisbeto
Copy link
Member Author

crisbeto commented Apr 2, 2020

I've addressed the feedback @AndrewKushnir. Also sorry for the larger diff, clang-format ended up reformatting the files I changed.

@crisbeto crisbeto force-pushed the FW-1974/creation-error-mask branch from 113648d to 3113e17 Compare April 4, 2020 08:44
@crisbeto crisbeto marked this pull request as draft April 15, 2020 15:32
@crisbeto crisbeto force-pushed the FW-1974/creation-error-mask branch from 3113e17 to cedc991 Compare April 20, 2020 18:49
@crisbeto crisbeto changed the title fix(core): user errors during creation masked by framework errors fix(core): attempt to recover from user errors during creation Apr 20, 2020
@crisbeto crisbeto marked this pull request as ready for review April 20, 2020 19:10
@crisbeto
Copy link
Member Author

crisbeto commented Apr 20, 2020

This is ready for review again. Also thanks @pkozlowski-opensource for the help with the test cases.

* Indicates that there was an error before we managed to complete the first create pass of the
* view. This means that the view is likely corrupted and we should try to recover it.
*/
incompleteFirstPass: boolean;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of potentially making this a counter so that we can stop trying after a certain number of attempts. I decided to keep it simple for now, but I'm open to changing it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, I think that keeping it simple for now is the way to go 👍

Copy link
Member

@pkozlowski-opensource pkozlowski-opensource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

* Indicates that there was an error before we managed to complete the first create pass of the
* view. This means that the view is likely corrupted and we should try to recover it.
*/
incompleteFirstPass: boolean;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, I think that keeping it simple for now is the way to go 👍

@@ -398,11 +398,11 @@ describe('view insertion', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();

expect(fixture.debugElement.nativeElement.textContent).toBe('start|test|end');
expect(fixture.nativeElement.textContent).toBe('start|test|end');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


fixture.componentInstance.insertTpl = true;
fixture.detectChanges();
expect(fixture.debugElement.nativeElement.textContent).toBe('start|testtest|end');
expect(fixture.nativeElement.textContent).toBe('start|testtest|end');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@pkozlowski-opensource pkozlowski-opensource added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 28, 2020
@AndrewKushnir AndrewKushnir added the action: presubmit The PR is in need of a google3 presubmit label Apr 28, 2020
@AndrewKushnir
Copy link
Contributor

Presubmit

@AndrewKushnir AndrewKushnir added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: presubmit The PR is in need of a google3 presubmit action: merge The PR is ready for merge by the caretaker labels Apr 28, 2020
@AndrewKushnir
Copy link
Contributor

@crisbeto could you please rebase this PR? There is no conflict, but the merge script failed since this PR was rebased/created prior to the most recent update of the base SHA in the merge script. Feel free to add "merge" label back once it's done.

FYI, g3 presubmit is successful.

If there's an error during the first creation pass of a `TView`, the data structure may be corrupted which will cause framework assertion failures downstream which can mask the user's error. These changes add a new flag to the `TView` that indicates whether the first creation pass was successful, and if it wasn't we try re-create the `TView`.

Fixes angular#31221.
@crisbeto crisbeto force-pushed the FW-1974/creation-error-mask branch from cedc991 to c497fe1 Compare April 28, 2020 19:07
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Apr 28, 2020
@crisbeto
Copy link
Member Author

Rebased.

@AndrewKushnir AndrewKushnir added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: merge The PR is ready for merge by the caretaker labels Apr 28, 2020
@AndrewKushnir
Copy link
Contributor

@crisbeto thanks for rebasing! It looks like payload size limit checks failed on CI, could you please have a look when you get a chance? Thank you.

@crisbeto crisbeto force-pushed the FW-1974/creation-error-mask branch from 180df60 to 77c64ee Compare April 28, 2020 20:02
@crisbeto
Copy link
Member Author

Fixed the payload size failures.

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Apr 28, 2020
@AndrewKushnir
Copy link
Contributor

Thanks @crisbeto.

I've re-requested review from @IgorMinar to review/approve payload size increase.

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for size changes (look like accumulation)

@@ -30,7 +30,7 @@
"master": {
"uncompressed": {
"runtime-es2015": 1485,
"main-es2015": 137320,
"main-es2015": 137897,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is mostly accumulation from other PRs? The change itself doesn't seem to merit this jump in size.

Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! Thanks!

AndrewKushnir pushed a commit that referenced this pull request Apr 29, 2020
If there's an error during the first creation pass of a `TView`, the data structure may be corrupted which will cause framework assertion failures downstream which can mask the user's error. These changes add a new flag to the `TView` that indicates whether the first creation pass was successful, and if it wasn't we try re-create the `TView`.

Fixes #31221.

PR Close #36381
@angular-automatic-lock-bot
Copy link

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 May 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes target: patch This PR is targeted for the next patch release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ivy preview report: Error: ASSERTION ERROR: Reached the max number of directives
6 participants