Skip to content

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

Merged
connorjclark merged 5 commits into
GoogleChrome:mainfrom
Nithin0620:fix/insight-audit-navigation-id-match
Oct 8, 2026
Merged

connorjclark merged 5 commits 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
@Nithin0620

Copy link
Copy Markdown
Contributor Author

@connorjclark @paulirish

I’ve fixed the cause of the E2E test failure. Could you please re-run the tests and review this PR?

Thank you!

@connorjclark

Copy link
Copy Markdown
Collaborator

Thanks for finding this. It's a big bug to have missed. I appreciate the fix!

I believe the impact is scoped to just user flows with multiple navigations.

@connorjclark

Copy link
Copy Markdown
Collaborator

The failures in CI are unrelated to your changes, please ignore.

@connorjclark
connorjclark merged commit 22de073 into GoogleChrome:main Oct 8, 2026
31 of 33 checks passed
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.

2 participants