4

I encountered the following error in an angular2 application.

 WARNING: your application is taking longer than 2000 Zone turns.

My question: What are 'zone turns', why does it warn me when it is above 2000? (I know I can change the limit, but then, why would I do this?)

Dylan Meeus
  • 5,696
  • 2
  • 30
  • 49

1 Answers1

3

This error is produce by Angular2/Universal. When the zones microtask queue is processed and after processing 2000 tasks from the queue there are still pending tasks. This might be caused by lots of async work that itself enqueues lots of async tasks. Angular expects the queue to eventually become empty.

https://github.com/angular/universal/issues/377#issuecomment-215229702

you can set maxZoneTurns to 10000 if you like or higher

The source where the error is created https://github.com/angular/universal/blob/9508ac03650ca0439192b8ed49ce8f1e57b6be33/modules/universal/src/node/bootloader.ts#L158

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • So in essence, the warning is because the async tasks could be a performance hit? Also, what is seen as a task? One task = one instruction? Or one async task = one promise. Thank you for the answer you have already provided! – Dylan Meeus May 09 '16 at 11:41
  • It seems to be one microtask but I'm not sure. I'd say "one promise" is probably pretty close. Also other async tasks like received DOM events or `setTimeout(...)` calls. – Günter Zöchbauer May 09 '16 at 11:44