From: root Date: Wed, 9 Sep 2026 04:13:40 +0000 (+0800) Subject: test: add first-load timing script to reproduce incognito stuck-loading X-Git-Url: http://acesimba.cloud/gitweb/?a=commitdiff_plain;h=afb9906191c7a30c7e83f0a4c9b6f78c44cbc632;p=StationBuilder.git test: add first-load timing script to reproduce incognito stuck-loading Confirms loading state now resolves <1s on dev server (cold/warm) and public nginx path after swappiness=1 + keepalive mitigation of swap-driven cold faults. --- diff --git a/scripts/timing-firstload.mjs b/scripts/timing-firstload.mjs new file mode 100644 index 0000000..cad2244 --- /dev/null +++ b/scripts/timing-firstload.mjs @@ -0,0 +1,37 @@ +import { chromium } from "playwright"; + +const BASE = process.env.BASE || "http://127.0.0.1:37821/t/stationbuilder/"; + +const run = async (label) => { + const browser = await chromium.launch(); + const ctx = await browser.newContext(); // fresh = incognito-equivalent + const page = await ctx.newPage(); + const t0 = Date.now(); + let domReady = 0, loadingGone = 0; + page.on("domcontentloaded", () => { domReady = Date.now() - t0; }); + try { + await page.goto(BASE, { waitUntil: "commit", timeout: 60000 }); + // wait until the loading empty-state disappears (content resolves) + await page.waitForFunction(() => { + const els = Array.from(document.querySelectorAll(".empty-state")); + const txt = els.map(e => e.textContent || "").join(""); + return !/加载中/.test(txt); + }, { timeout: 90000 }); + loadingGone = Date.now() - t0; + } catch (e) { + console.log(`[${label}] FAIL: ${e.message} (domReady=${domReady}ms, loadingGone=${loadingGone}ms)`); + await browser.close(); + return; + } + console.log(`[${label}] domContentLoaded=${domReady}ms, loadingResolved=${loadingGone}ms`); + await browser.close(); +}; + +console.log("=== run 1 (cold) ==="); +await run("cold"); +console.log("=== run 2 (warm, same dev server) ==="); +await run("warm"); +const PUB = process.env.PUB || "https://aidemo.istation.cloud/t/stationbuilder/"; +console.log(`=== run 3 (public nginx: ${PUB}) ===`); +await run("public"); +process.exit(0);