Files
novalon-website/docs/acceptance/2026-10-20-prod-about/probe-contact.mjs
zhangxiang 702c732d27 fix(contact): 去掉 useSearchParams 让 /contact 可完整预渲染;补发布后 ISR 预热脚本
冷首访白屏的第二个真因:/contact 用 useSearchParams() 读 ?success,客户端组件里
这会让整页在预渲染时退化成 Suspense fallback(首访只看到「加载中…」,限速下 ~6s 才出内容)。
该参数只用于一次性成功提示 ⇒ 改为挂载后从 window.location 读并 replaceState 清理。

- /contact 冷首访 h1 可见:6.0s → 1.5s;HTML 73KB 含正文(此前只有外壳)。
- 新增 scripts/ops/warm-routes.mjs:按 sitemap 预热并断言全 200、第二遍 <1500ms 或 HIT;
  本轮线上第二遍:非 200 = 0、>1500ms = 0。
- 全站冷首访复测:/ 827ms、/about 1652ms、/contact 1511ms、/products 917ms、
  /services/software 922ms、/insights 1532ms。
- runbook:加发布前磁盘检查(≥2G)与「构建失败必须中止」;加 §4.0 预热步骤。
- 事故记录:第三次重建时服务器磁盘 99%,COPY 报 ENOSPC 而 up -d 仍执行(旧镜像被当已发布);
  清理旧备份 1.8G + docker image prune 1.075G 后回到 81%,重建 015b6d75 成功。
2026-10-20 08:23:34 +08:00

26 lines
1.4 KiB
JavaScript

import { chromium } from 'playwright';
const b = await chromium.launch();
const ctx = await b.newContext({ viewport:{width:1280,height:900} });
const p = await ctx.newPage();
const cdp = await ctx.newCDPSession(p);
await cdp.send('Network.enable');
await cdp.send('Network.setCacheDisabled', { cacheDisabled: true });
await cdp.send('Network.emulateNetworkConditions', { offline:false, latency:150, downloadThroughput: 900*1024/8, uploadThroughput: 400*1024/8 });
p.goto('https://www.novalon.cn/contact', { waitUntil:'commit', timeout:90000 }).catch(()=>{});
for (let i=0;i<8;i++) {
await p.waitForTimeout(1000);
const s = await p.evaluate(() => {
const h1 = document.querySelector('h1');
const ready = document.documentElement.getAttribute('data-content-ready');
const text = (document.body?.innerText||'').trim().length;
const zeros = [...document.querySelectorAll('body *')].filter(e=>parseFloat(getComputedStyle(e).opacity)===0).length;
return { t: Math.round(performance.now()), h1: !!h1, h1txt: h1?.innerText?.slice(0,20) ?? null,
h1op: h1 ? getComputedStyle(h1).opacity : null, ready, text, zeros,
parentOp: h1?.parentElement ? getComputedStyle(h1.parentElement).opacity : null };
}).catch(()=>null);
console.log(JSON.stringify(s));
if (s && s.h1op === '1') break;
}
await p.screenshot({ path:'docs/acceptance/2026-10-20-prod-about/contact-cold.png' });
await b.close();