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): Add an error state for ChangeDetectors that is set when bindings or lifecycle events throw exceptions and prevents further detection. #4953

Closed
wants to merge 1 commit into from

Conversation

alxhub
Copy link
Member

@alxhub alxhub commented Oct 27, 2015

  • Changes the alreadyChecked flag of AbstractChangeDetector to a new state flag.
  • Changes all checks of alreadyChecked to check that the state is NeverChecked.
  • Set state to Errored if an error is thrown during detection.
  • Skip change detection for a detector and its children when the state is Errored.
  • Add a test to validate this fixes issue Change detection error -> infinite loop #4323.

@alxhub alxhub added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 27, 2015
@@ -423,7 +426,7 @@ export class ChangeDetectorJITGenerator {
/** @internal */
_genOnInit(r: ProtoRecord): string {
var br = r.bindingRecord;
return `if (!throwOnChange && !${this._names.getAlreadyCheckedName()}) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.onInit();`;
return `if (!throwOnChange && ${this._names.getStateName()} == ${this.changeDetectorStateVarName}.NeverChecked) ${this._names.getDirectiveName(br.directiveRecord.directiveIndex)}.onInit();`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Even though it does not matter in this case, but could you use === instead of ==?

@vsavkin vsavkin assigned alxhub and unassigned vsavkin Oct 27, 2015
@vsavkin vsavkin removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 27, 2015
@mhevery mhevery added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Oct 28, 2015
@alxhub alxhub force-pushed the cd-loop branch 3 times, most recently from 3ce47fe to 4f698a4 Compare October 28, 2015 23:16
…ndings or lifecycle events throw exceptions and prevents further detection.

- Changes the `alreadyChecked` flag of AbstractChangeDetector to a new `state` flag.
- Changes all checks of alreadyChecked to check that the state is NeverChecked.
- Set state to Errored if an error is thrown during detection.
- Skip change detection for a detector and its children when the state is Errored.
- Add a test to validate this fixes issue angular#4323.
@alxhub alxhub 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 Oct 29, 2015
@mary-poppins
Copy link

Merging PR #4953 on behalf of @alxhub to branch presubmit-alxhub-pr-4953.

@mary-poppins mary-poppins removed the action: merge The PR is ready for merge by the caretaker label Oct 29, 2015
@alxhub alxhub closed this in d1b54d6 Oct 29, 2015
@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 Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants