lighthouse 10.2.0-dev.20230522 → 10.2.0-dev.20230523

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -341,6 +341,7 @@ class NetworkRequest {
341
341
 
342
342
  if (response.protocol) this.protocol = response.protocol;
343
343
 
344
+ // This is updated in _recomputeTimesWithResourceTiming, if timings are present.
344
345
  this.responseHeadersEndTime = timestamp * 1000;
345
346
 
346
347
  this.transferSize = response.encodedDataLength;
@@ -372,16 +373,27 @@ class NetworkRequest {
372
373
  // Don't recompute times if the data is invalid. RequestTime should always be a thread timestamp.
373
374
  // If we don't have receiveHeadersEnd, we really don't have more accurate data.
374
375
  if (timing.requestTime === 0 || timing.receiveHeadersEnd === -1) return;
376
+
375
377
  // Take networkRequestTime and responseHeadersEndTime from timing data for better accuracy.
378
+ // Before this, networkRequestTime and responseHeadersEndTime were set to bogus values based on
379
+ // CDP event timestamps, though they should be somewhat close to the network timings.
380
+ // Note: requests served from cache never run this function, so they use the "bogus" values.
381
+
376
382
  // Timing's requestTime is a baseline in seconds, rest of the numbers there are ticks in millis.
383
+ // See https://raw.githubusercontent.com/GoogleChrome/lighthouse/main/docs/Network-Timings.svg
377
384
  this.networkRequestTime = timing.requestTime * 1000;
378
385
  const headersReceivedTime = this.networkRequestTime + timing.receiveHeadersEnd;
379
- if (!this.responseHeadersEndTime || this.responseHeadersEndTime < 0) {
380
- this.responseHeadersEndTime = headersReceivedTime;
381
- }
382
-
383
- this.responseHeadersEndTime = Math.min(this.responseHeadersEndTime, headersReceivedTime);
386
+ // This was set in `_onResponse` as that event's timestamp.
387
+ const responseTimestamp = this.responseHeadersEndTime;
388
+
389
+ // Update this.responseHeadersEndTime. All timing values from the netstack (timing) are well-ordered, and
390
+ // so are the timestamps from CDP (which this.responseHeadersEndTime belongs to). It shouldn't be possible
391
+ // that this timing from the netstack is greater than the onResponse timestamp, but just to ensure proper order
392
+ // is maintained we bound the new timing by the network request time and the response timestamp.
393
+ this.responseHeadersEndTime = headersReceivedTime;
394
+ this.responseHeadersEndTime = Math.min(this.responseHeadersEndTime, responseTimestamp);
384
395
  this.responseHeadersEndTime = Math.max(this.responseHeadersEndTime, this.networkRequestTime);
396
+
385
397
  // We're only at responseReceived (_onResponse) at this point.
386
398
  // This networkEndTime may be redefined again after onLoading is done.
387
399
  this.networkEndTime = Math.max(this.networkEndTime, this.responseHeadersEndTime);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "10.2.0-dev.20230522",
4
+ "version": "10.2.0-dev.20230523",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {