question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[platform-server] console.log in certain lifecycle hooks could cause an infinite loop since it results in a microtask on Node.JS (was: ngAfterViewChecked causes infinite loop)

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report

Current behavior Adding ngAfterViewChecked() { } (even if blank) to any Component causes infinite loop and server-render timesout.

Expected behavior Let the zone stabilize and render the application.

Minimal reproduction of the problem with instructions This branch here: https://github.com/MarkPieszak/ng-universal-demo/tree/ngAfterViewChecked-bug

You can see the only addition was: https://github.com/MarkPieszak/ng-universal-demo/blob/ngAfterViewChecked-bug/src/app/app.component.ts#L24-L26

What is the motivation / use case for changing the behavior? Lifecycle hooks fix.

Please tell us about your environment: This happens in Node/express and also ASP.NET Core/Node

  • Angular version: 4.x

  • Node (for AoT issues): node --version = Any version (tested on 6.x, 7.x, 8.0)

cc/ @alxhub @vikerman @gdi2290

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
schippiecommented, Jun 14, 2017

I’ve been slamming my head in against a wall for 3 whole days before finding that the issue is due to the console.log statement. @gdi2290 where do I alter the isStable logic?

1reaction
hanslcommented, Jun 19, 2017

This is a Zone issue (rather than change detection one) because any task that would call console.log from a begin/end zone hook would also cause this infinite loop.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implementing AfterViewInit causes an endless loop of event ...
I had the same problem. The ngAfterViewChecked is called 3 times everytime the component detects some changes.
Read more >
The Curious Case of Angular and the Infinite Change Event ...
In the hello component we log every time the ngAfterViewChecked Angular lifecycle hook is invoked. Infinite Event Loop. Now, let's say we want ......
Read more >
angular/core - UNPKG
The CDN for @angular/core. ... 146, * Trigger a change detection cycle for the component. ... fn, 'Calling ɵɵinject would cause infinite recursion');....
Read more >
(PDF) Ngcourse | Văn Huy Nguyễn - Academia.edu
Angular avoids an infinite loop by breaking the cycle when characterForm and ... This will produce modules that are compatible with node.js's module...
Read more >
fesm2015/core.js - Bundle Scanner
The parts of the code that are highlighted in grey are tokens that can be found in both places. Click on a token...
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