core: fix insight audits picking the wrong navigation's data - #17174
Open
Nithin0620 wants to merge 1 commit into
Open
core: fix insight audits picking the wrong navigation's data#17174Nithin0620 wants to merge 1 commit into
Nithin0620 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getInsightSetincore/audits/insights/insight-audit.js:32to select the insight set whosenavigationIdmatches the audited trace'snavigationIdgetInsightSetfor unit testingWhy it matters
A trace can contain multiple main-frame navigationStarts (client-side redirects — exactly what the
redirectsaudit flags). Lighthouse'stimeOriginEvtis 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
timeOriginEvt → nav '2'pickedNAVIGATION_1before the fix,NAVIGATION_2aftercore/computed/navigation-insights.js:30core/test/audits/insights/insight-audit-test.js) that fail onmainand pass with the fixyarn mocha core/test/audits/insights/(21 tests) green;type-checkandeslintclean;update:sample-jsonproduces no relevant diffs