Budget gate: Next's idle link prefetches counted apart, third parties recorded then aborted, spec filter safe for any checkout path; zero counted queries fail
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
beef517c23
commit
3b32e659c5
@@ -14,7 +14,8 @@ import { measureMedian } from './perf-lab.mjs'
|
||||
* and a desktop, first visit. The numbers are this site's own, measured on 2026-12-01 (docs/dev/perf/*-after.json)
|
||||
* with headroom for lab noise: a change that makes a page heavier or slower fails here, in `pnpm e2e:built`, with both
|
||||
* bundlers. Loosen a number only with a reason in the comment next to it.
|
||||
* PERF_RUNS (default 1) runs per page; the gate takes the median.
|
||||
* PERF_RUNS (default 1) runs per page; the gate takes the median. Third-party requests are recorded (none may come
|
||||
* before consent) and aborted, so an external host's speed cannot fail or hang the gate.
|
||||
*/
|
||||
const runs = Number(process.env.PERF_RUNS ?? 1)
|
||||
|
||||
@@ -56,7 +57,7 @@ test.describe('performance budgets', () => {
|
||||
for (const profile of ['mobile', 'desktop'] as const) {
|
||||
test(`${page.name} (${profile}) stays within its budget`, async ({ baseURL }) => {
|
||||
const budget = { ...budgets[profile], ...page.budget?.[profile] }
|
||||
const measured = await measureMedian(browser, `${baseURL}${page.path}`, profile, runs)
|
||||
const measured = await measureMedian(browser, `${baseURL}${page.path}`, profile, runs, { blockThirdParty: true })
|
||||
test.info().annotations.push({ description: JSON.stringify({ bytes: measured.bytes, cls: measured.cls, inp: measured.inp, lcp: measured.lcp, requests: measured.requests, tbt: measured.tbt }), type: 'measured' })
|
||||
expect(overBudget(measured, budget), `${page.path} ${profile}${page.why ? ` (${page.why})` : ''}`).toEqual([])
|
||||
// the LCP image is never lazy (web.dev/articles/lcp-lazy-loading)
|
||||
@@ -99,6 +100,7 @@ test.describe('queries per render', () => {
|
||||
expect(res.status).toBe(200)
|
||||
await db.command({ profile: 0 })
|
||||
counts[p] = await db.collection('system.profile').countDocuments({ ns: { $not: /system\.profile$/ }, op: 'query' })
|
||||
expect(counts[p], `${p}: no query counted — the profiler did not record this database`).toBeGreaterThan(0)
|
||||
expect(counts[p], `${p}: ${counts[p]} queries (budget ${limit}, plugin default ${SERVER_BUDGET.queriesPerRender})`).toBeLessThanOrEqual(limit)
|
||||
}
|
||||
test.info().annotations.push({ description: JSON.stringify(counts), type: 'queries' })
|
||||
|
||||
Reference in New Issue
Block a user