Daniel Kucal
Daniel Kucal

Reputation: 9232

Angular PWA never entering into stable state

The Angular application I'm working on never gets into stable state, basing on ApplicationRef.isStable, which only emits false once. According to Angular docs:

the application will never be stable if you start any kind of recurrent asynchronous task when the application starts (for example for a polling process, started with a setInterval, a setTimeout or using RxJS operators like interval);

So I've reviewed all usages of setTimeout(), setInterval() (none) and RxJS' interval(), which I delayed until appRef.isStable gives true and the same with SignalR (kind of websocket) connection, but it all didn't help. I was trying to use DevTools' Performance, Memory and LightHouse tools to find the source of this unwanted behavior, but the only running task I've seen (for the first half of second in Performance tab) was from zone.js and slightly growing JS Heap: enter image description here

In the Network tab nothing happens except pending connection with Angular's 127.0.0.1:4200/sockjs-node/*/websocket on dev server, which I guess is fine. The same behavior (except Angular's websocket) can be seen consistently on all production environments.

Is there any way to debug it in order to find a reason for that? Any other advise?

Upvotes: 3

Views: 1185

Answers (2)

Matthieu Riegler
Matthieu Riegler

Reputation: 54998

Just to complete Daniel's anwser;

This behavior will happen every time a macrotask (setInterval, setTimeout etc.) is called in the bootstraping phase of your app and it looks like windowTime (like every other RxJS timed operators) uses one of them.

Upvotes: 0

Daniel Kucal
Daniel Kucal

Reputation: 9232

It was caused by RxJS' windowTime() operator.

Upvotes: 1

Related Questions