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(network-recorder): remove quic-request-finished workaround #9744

Merged
merged 2 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 3 additions & 25 deletions lighthouse-core/lib/network-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class NetworkRecorder extends EventEmitter {
* @return {Array<LH.Artifacts.NetworkRequest>}
*/
getInflightRecords() {
return this._records.filter(record => !NetworkRecorder.isNetworkRecordFinished(record));
return this._records.filter(record => !record.finished);
}

getRecords() {
Expand Down Expand Up @@ -72,7 +72,7 @@ class NetworkRecorder extends EventEmitter {

for (let i = 0; i < this._records.length; i++) {
const record = this._records[i];
if (NetworkRecorder.isNetworkRecordFinished(record)) continue;
if (record.finished) continue;
if (IGNORED_NETWORK_SCHEMES.includes(record.parsedURL.scheme)) continue;
inflightRequests++;
}
Expand All @@ -99,28 +99,6 @@ class NetworkRecorder extends EventEmitter {
}
}

/**
* QUIC network requests don't always "finish" even when they're done loading data, use recievedHeaders
* @see https://github.com/GoogleChrome/lighthouse/issues/5254
* @param {LH.Artifacts.NetworkRequest} record
* @return {boolean}
*/
static _isQUICAndFinished(record) {
const isQUIC = record.responseHeaders && record.responseHeaders
.some(header => header.name.toLowerCase() === 'alt-svc' && /quic/.test(header.value));
const receivedHeaders = record.timing && record.timing.receiveHeadersEnd > 0;
return !!(isQUIC && receivedHeaders && record.endTime);
}

/**
* @param {LH.Artifacts.NetworkRequest} record
* @return {boolean}
*/
static isNetworkRecordFinished(record) {
return record.finished ||
NetworkRecorder._isQUICAndFinished(record);
}

/**
* Finds all time periods where the number of inflight requests is less than or equal to the
* number of allowed concurrent requests.
Expand All @@ -141,7 +119,7 @@ class NetworkRecorder extends EventEmitter {

// convert the network record timestamp to ms
timeBoundaries.push({time: record.startTime * 1000, isStart: true});
if (NetworkRecorder.isNetworkRecordFinished(record)) {
if (record.finished) {
timeBoundaries.push({time: record.endTime * 1000, isStart: false});
}
});
Expand Down
4 changes: 1 addition & 3 deletions lighthouse-core/test/lib/network-recorder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,7 @@ describe('network recorder', function() {
];

const periods = NetworkRecorder.findNetworkQuietPeriods(records, 0);
assert.deepStrictEqual(periods, [
{start: 2000, end: Infinity},
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we just change this to assert that there's no idle period here?

Copy link
Member Author

Choose a reason for hiding this comment

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

should we just change this to assert that there's no idle period here?

sounds good

]);
assert.deepStrictEqual(periods, []);
});
});
});