lighthouse 11.4.0-dev.20240104 → 11.4.0-dev.20240106

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.
@@ -540,7 +540,7 @@ function waitForUserToContinue(driver) {
540
540
  }
541
541
  /* c8 ignore stop */
542
542
 
543
- driver.defaultSession.setNextProtocolTimeout(2 ** 31 - 1);
543
+ driver.defaultSession.setNextProtocolTimeout(Infinity);
544
544
  return driver.executionContext.evaluate(createInPagePromise, {args: []});
545
545
  }
546
546
 
@@ -10,6 +10,17 @@ import {LighthouseError} from '../lib/lh-error.js';
10
10
 
11
11
  // Controls how long to wait for a response after sending a DevTools protocol command.
12
12
  const DEFAULT_PROTOCOL_TIMEOUT = 30000;
13
+ const PPTR_BUFFER = 50;
14
+
15
+ /**
16
+ * Puppeteer timeouts must fit into an int32 and the maximum timeout for `setTimeout` is a *signed*
17
+ * int32. However, this also needs to account for the puppeteer buffer we add to the timeout later.
18
+ *
19
+ * So this is defined as the max *signed* int32 minus PPTR_BUFFER.
20
+ *
21
+ * In human terms, this timeout is ~25 days which is as good as infinity for all practical purposes.
22
+ */
23
+ const MAX_TIMEOUT = 2147483647 - PPTR_BUFFER;
13
24
 
14
25
  /** @typedef {LH.Protocol.StrictEventEmitterClass<LH.CrdpEvents>} CrdpEventMessageEmitter */
15
26
  const CrdpEventEmitter = /** @type {CrdpEventMessageEmitter} */ (EventEmitter);
@@ -70,6 +81,7 @@ class ProtocolSession extends CrdpEventEmitter {
70
81
  * @param {number} ms
71
82
  */
72
83
  setNextProtocolTimeout(ms) {
84
+ if (ms > MAX_TIMEOUT) ms = MAX_TIMEOUT;
73
85
  this._nextProtocolTimeout = ms;
74
86
  }
75
87
 
@@ -86,15 +98,16 @@ class ProtocolSession extends CrdpEventEmitter {
86
98
  /** @type {NodeJS.Timer|undefined} */
87
99
  let timeout;
88
100
  const timeoutPromise = new Promise((resolve, reject) => {
89
- if (timeoutMs === Infinity) return;
90
-
91
101
  // eslint-disable-next-line max-len
92
102
  timeout = setTimeout(reject, timeoutMs, new LighthouseError(LighthouseError.errors.PROTOCOL_TIMEOUT, {
93
103
  protocolMethod: method,
94
104
  }));
95
105
  });
96
106
 
97
- const resultPromise = this._cdpSession.send(method, ...params);
107
+ const resultPromise = this._cdpSession.send(method, ...params, {
108
+ // Add 50ms to the Puppeteer timeout to ensure the Lighthouse timeout finishes first.
109
+ timeout: timeoutMs + PPTR_BUFFER,
110
+ });
98
111
  const resultWithTimeoutPromise = Promise.race([resultPromise, timeoutPromise]);
99
112
 
100
113
  return resultWithTimeoutPromise.finally(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "11.4.0-dev.20240104",
4
+ "version": "11.4.0-dev.20240106",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {
@@ -166,7 +166,7 @@
166
166
  "pako": "^2.0.3",
167
167
  "preact": "^10.7.2",
168
168
  "pretty-json-stringify": "^0.0.2",
169
- "puppeteer": "^21.5.2",
169
+ "puppeteer": "^21.7.0",
170
170
  "resolve": "^1.22.1",
171
171
  "rollup": "^2.52.7",
172
172
  "rollup-plugin-polyfill-node": "^0.12.0",
@@ -200,7 +200,7 @@
200
200
  "open": "^8.4.0",
201
201
  "parse-cache-control": "1.0.1",
202
202
  "ps-list": "^8.0.0",
203
- "puppeteer-core": "^21.5.2",
203
+ "puppeteer-core": "^21.7.0",
204
204
  "robots-parser": "^3.0.1",
205
205
  "semver": "^5.3.0",
206
206
  "speedline-core": "^1.4.3",