Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(total-byte-weight): count partially finished requests #12665

Merged
merged 3 commits into from
Jun 21, 2021

Conversation

patrickhulce
Copy link
Collaborator

Summary
Removes the total byte weight policy that ignored partially downloaded resources (like videos). IMO, this dramatically understates the weight of a page in some cases (see #12664).

The check was added way back in 2017 by me as part of adding visibility into inflight records 🤯 . This was also before we used our own network request class that initializes transferSize that prevents the undefined concern that prompted the original.

Nonetheless, I added a test to ensure spirit of the condition is still handled.

Related Issues/PRs
closes #12664

@patrickhulce patrickhulce requested a review from a team as a code owner June 15, 2021 22:14
@patrickhulce patrickhulce requested review from adamraine and removed request for a team June 15, 2021 22:14
@google-cla google-cla bot added the cla: yes label Jun 15, 2021
@@ -115,7 +115,8 @@ function getResponseReceivedEvent(networkRecord, index) {
connectionId: networkRecord.connectionId || 140,
fromDiskCache: networkRecord.fromDiskCache || false,
fromServiceWorker: networkRecord.fetchedViaServiceWorker || false,
encodedDataLength: networkRecord.transferSize || 0,
encodedDataLength: typeof networkRecord.transferSize === 'undefined' ?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't understand the note about undefined. Why does this need to change?

Don't need to do typeof here, just networkRecord.transferSize === undefined works. Or if the data type is somehow uncertain, flip the logic to typeof networkRecord.transferSize === 'number' ? networkRecord.transferSize : 0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to do typeof here

ah yes, old habits :)

Or if the data type is somehow uncertain, flip the logic to

The spirit of the original I assumed was ?? 0, i.e. use 0 as a default if some value is not explicitly set. That seems better than ignoring all values that aren't numbers.

I didn't understand the note about undefined. Why does this need to change?

If we are ever to test unexpected values coming from the protocol, we need a mechanism to mock those values in the devtools log. The affected code was attempting to handle such unexpected values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarification about "total-byte-weight" audit
4 participants