Skip to content

core: fix insight audits picking the wrong navigation's data - #17174

Open
Nithin0620 wants to merge 1 commit into
GoogleChrome:mainfrom
Nithin0620:fix/insight-audit-navigation-id-match
Open

core: fix insight audits picking the wrong navigation's data#17174
Nithin0620 wants to merge 1 commit into
GoogleChrome:mainfrom
Nithin0620:fix/insight-audit-navigation-id-match

Conversation

@Nithin0620

Copy link
Copy Markdown
Contributor

Summary

  • Fix getInsightSet in core/audits/insights/insight-audit.js:32 to select the insight set whose navigationId matches the audited trace's navigationId
  • Previously it used a truthiness check, so it picked the first insight set belonging to any navigation
  • Export getInsightSet for unit testing

Why it matters

A trace can contain multiple main-frame navigationStarts (client-side redirects — exactly what the redirects audit flags). Lighthouse's timeOriginEvt is the last navigation, but the old code selected the first one's insight set. Result: all ~17 insight audits (lcp-discovery, lcp-breakdown, inp-breakdown, cls-culprits, font-display, render-blocking, document-latency, viewport, etc.) showed the wrong navigation's advice on redirected pages — often empty/wrong LCP, INP, or CLS rows.

Verification

  • Reproduced the mismatch empirically: a 2-navigation trace with timeOriginEvt → nav '2' picked NAVIGATION_1 before the fix, NAVIGATION_2 after
  • Matches the existing correct pattern in core/computed/navigation-insights.js:30
  • Added regression tests (new core/test/audits/insights/insight-audit-test.js) that fail on main and pass with the fix
  • yarn mocha core/test/audits/insights/ (21 tests) green; type-check and eslint clean; update:sample-json produces no relevant diffs

getInsightSet selected the first insight set belonging to *any*
navigation instead of the one matching the audited navigationId. On
traces with multiple navigationStarts (e.g. client-side redirects),
all insight audits (lcp-discovery, inp-breakdown, cls-culprits, etc.)
used an earlier navigation's data, producing wrong or missing advice.
Compare the insight set's navigationId with the trace's navigationId,
matching the existing pattern in navigation-insights.js. Export
getInsightSet for testing and add regression tests that fail on the
old code and pass now.
@Nithin0620
Nithin0620 requested a review from a team as a code owner August 16, 2026 06:52
@Nithin0620
Nithin0620 requested review from paulirish and removed request for a team August 16, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant