Skip to content

Commit d2a12f5

Browse files
committed
fix(docs): attribute benchmark metrics to their source document
1 parent 8153449 commit d2a12f5

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎apps/docs/scripts/benchmark-readiness.ts‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ async function save() {
174174
'Visible article images have decoded; measured separately from useful article paint.',
175175
navigation:
176176
'Existing site links only. No-hover case aborts prefetch requests and has HTTP cache disabled by Playwright routing. Intent case preserves normal caching and allows 500ms hover/focus dwell.',
177+
documentLcp:
178+
'LCP entries belong to their recorded document URL, not a subsequent client-side destination. Use meaningfulPaintMs for client-side navigation.',
177179
mobileNetwork:
178180
'Chromium CDP: 150ms latency, 1.6Mbps download, 750Kbps upload, 4x CPU slowdown.',
179181
lighthouse:
@@ -340,11 +342,17 @@ async function contextFor(browser: Browser, profile: Profile, disablePrefetch =
340342
network.push(record)
341343
})
342344
page.on('response', (response) => {
343-
if (response.status() === 403 && new URL(response.url()).origin === base.origin) {
345+
const request = response.request()
346+
if (
347+
response.status() === 403 &&
348+
new URL(response.url()).origin === base.origin &&
349+
request.isNavigationRequest() &&
350+
request.frame() === page.mainFrame()
351+
) {
344352
originBlocked = { url: response.url(), status: 403, observedAt: new Date().toISOString() }
345353
void context.close().catch(() => {})
346354
}
347-
const record = requests.get(response.request())
355+
const record = requests.get(request)
348356
if (!record) return
349357
record.status = response.status()
350358
const headers = response.headers()
@@ -467,7 +475,10 @@ async function snapshot(page: Page, since = 0) {
467475
longTasks: state?.longTasks.filter((entry) => entry.startTime >= start),
468476
eventTimings: state?.events.filter((entry) => entry.startTime >= start),
469477
layoutShifts: state?.shifts.filter((entry) => entry.startTime >= start),
470-
lcp: state?.lcp,
478+
documentLcp: {
479+
url: performance.getEntriesByType('navigation')[0]?.name,
480+
entries: state?.lcp,
481+
},
471482
images: [...document.images].slice(0, 100).map((image) => {
472483
const bounds = image.getBoundingClientRect()
473484
return {

0 commit comments

Comments
 (0)