har: skip pages with no matching entries instead of throwing#2483
Merged
Conversation
Occasionally a HAR contains a page object whose pageref has no matching entries — typically a navigation that didn't produce any requests, or an extension-injected page. Three places in lib/support/har/index.js treated this shape as impossible: getDocumentRequests dereferenced the result of shift() without a guard, getFinalURL dereferenced the result of pop() without a guard, and getMainDocumentTimings wrapped its entire per-page loop in a single try/catch so one bad page wiped out the main-document timings for every other page in the same HAR. The downstream consequence was a noisy and confusing log triplet: a "page without an URL in the HAR" warning, a "Could not get main document timings TypeError: Cannot read properties of undefined (reading 'response')" error, and then in sitespeed.io a coach-data error because the timings array was empty. Guard the three known crash points and continue past pages that can't be resolved. The existing top-level try/catch in getMainDocumentTimings stays as a safety net; the existing unit tests still pass. Co-authored-by: Claude noreply@anthropic.com Change-Id: I5c6f2d7445bfdf1159c883f7dfc8f70d10bd3b32
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.
Occasionally a HAR contains a page object whose pageref has no matching
entries — typically a navigation that didn't produce any requests, or
an extension-injected page. Three places in lib/support/har/index.js
treated this shape as impossible: getDocumentRequests dereferenced the
result of shift() without a guard, getFinalURL dereferenced the result
of pop() without a guard, and getMainDocumentTimings wrapped its entire
per-page loop in a single try/catch so one bad page wiped out the
main-document timings for every other page in the same HAR.
The downstream consequence was a noisy and confusing log triplet: a
"page without an URL in the HAR" warning, a "Could not get main
document timings TypeError: Cannot read properties of undefined
(reading 'response')" error, and then in sitespeed.io a coach-data
error because the timings array was empty.
Guard the three known crash points and continue past pages that can't
be resolved. The existing top-level try/catch in
getMainDocumentTimings stays as a safety net; the existing unit tests
still pass.
Co-authored-by: Claude noreply@anthropic.com
Change-Id: I5c6f2d7445bfdf1159c883f7dfc8f70d10bd3b32