Search code examples
angularprogressive-web-appsservice-workerangular-service-workerangular-pwa

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?


Solution

  • It was caused by RxJS' windowTime() operator.