[Ivy] ASSERTION ERROR: Should be run in update mode

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package @angular/core (Ivy)

Is this a regression?

Yes, works in non-Ivy.

Description

I suspect this happens as a result of having an Input property that is set directly (isExpanded="true") instead of using a binding ([isExpanded]="true"), and having the property setter call changeDetectorRef.detectChanges(). It should be noted that this works in non-ivy.

πŸ”¬ Minimal Reproduction

https://github.com/fr0/angular-test/tree/ivy

  1. Clone repo
  2. git checkout ivy
  3. npm install
  4. npm start
  5. Open http://localhost:4200 in Chrome
  6. View browser console log

πŸ”₯ Exception or Error


core.js:5829 ERROR Error: ASSERTION ERROR: Should be run in update mode
    at throwError (core.js:1164)
    at assertEqual (core.js:1123)
    at refreshView (core.js:12425)
    at detectChangesInternal (core.js:13907)
    at ViewRef.detectChanges (core.js:15373)
    at ExpandableIfComponent.set isExpanded [as isExpanded] (expandable-if.component.ts:60)
    at setInputsFromAttrs (core.js:13579)
    at postProcessDirective (core.js:13335)
    at instantiateAllDirectives (core.js:13234)
    at createDirectivesInstances (core.js:12618)

🌍 Your Environment

Angular Version:




Angular CLI: 9.0.0-next.5
Node: 12.6.0
OS: darwin x64
Angular: 9.0.0-next.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-next.5
@angular-devkit/build-angular     0.900.0-next.5
@angular-devkit/build-optimizer   0.900.0-next.5
@angular-devkit/build-webpack     0.900.0-next.5
@angular-devkit/core              9.0.0-next.5
@angular-devkit/schematics        9.0.0-next.5
@angular/cli                      9.0.0-next.5
@ngtools/webpack                  9.0.0-next.5
@schematics/angular               9.0.0-next.5
@schematics/update                0.900.0-next.5
ng-packagr                        5.5.1
rxjs                              6.5.3
typescript                        3.5.3
webpack                           4.40.2
    

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:18
  • Comments:32 (5 by maintainers)

github_iconTop GitHub Comments

52reactions
BzenkoSergeycommented, May 16, 2020

oh, the same issue (angular 9.1.7 with { ngZone: β€˜noop’ })

resolved it by moving logic out of constructor to ngOnInit

6reactions
MartinJHammercommented, Aug 7, 2020

@BzenkoSergey It worked! You are a champ!

Looked through my company’s project for ALL logic defined in components constructors, and moved anything I found to ngOnInit, and bam, no error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASSERTION ERROR: Should be run in update mode ...
I got it all working,. I have placed the function getVersionInfos in the ngOnInit instead of inside the constructor.
Read more >
ASSERTION ERROR: Should be run in update mode ...
Coding example for the question how to fix Error: ASSERTION ERROR: Should be run in update mode [Expected=> false == true <=Actual]-angular.js.
Read more >
Template type checking - Angular
In the most basic type-checking mode, with the fullTemplateTypeCheck flag set to false , Angular validates only top-level expressions in a template.
Read more >
Problem with Assertion Error : r/Angular2 - Reddit
Well, I have a material table with expandable rows, a service that handles the addition of items to the table. So, this error...
Read more >
sbt/sbt - Gitter
What do I need to setup to use an external zinc server process for compilation? ... AssertionError: assumption failed: Constant pool entry is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found