/* _settle_worker.js -- the network keep-alive half of _chart_settle.js (see that file). * * Fetches a 1-byte file every 200ms so the page never goes network-idle while its flagship * chart is still mounting/animating. Runs on a Worker thread so it keeps ticking while the * main thread is blocked parsing the 10MB app bundle. Stops on the parent's "stop" message, * or after its own hard cap, whichever comes first -- so it can never wedge a capture. */ var PING_MS = 200; var MAX_PINGS = 90; // 18s ceiling; goto(networkidle) itself gives up at 30s var n = 0; function shutdown() { // Always let any in-flight ping settle before closing (see onmessage below). clearInterval(id); setTimeout(function () { self.close(); }, 1000); } var id = setInterval(function () { if (n >= MAX_PINGS) { shutdown(); return; } try { fetch('/_settle.txt?s=' + (n++), { cache: 'no-store' }).catch(function () {}); } catch (e) { shutdown(); } }, PING_MS); // Stop pinging, but do NOT close immediately: killing the worker while a ping is still in // flight leaves that request without a finished/failed event, and Playwright's networkidle // counter then never returns to zero -- the navigation hangs until goto()'s 30s timeout and // falls back to `domcontentloaded`, which is the very failure mode this shim exists to stop. self.onmessage = shutdown;