Skip to content

Commit

Permalink
core(network-recorder): remove quic-request-finished workaround (#9744)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Sep 27, 2019
1 parent da334b8 commit cb7140b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
28 changes: 3 additions & 25 deletions lighthouse-core/lib/network-recorder.js
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
Expand Up @@ -313,9 +313,7 @@ describe('network recorder', function() {
];

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

0 comments on commit cb7140b

Please sign in to comment.