lighthouse 12.0.0-dev.20240513 → 12.0.0-dev.20240514
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.
package/cli/run.js
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import os from 'os';
|
|
11
11
|
|
|
12
|
-
import psList from 'ps-list';
|
|
13
12
|
import * as ChromeLauncher from 'chrome-launcher';
|
|
14
13
|
import yargsParser from 'yargs-parser';
|
|
15
14
|
import log from 'lighthouse-logger';
|
|
@@ -176,36 +175,6 @@ async function saveResults(runnerResult, flags) {
|
|
|
176
175
|
}
|
|
177
176
|
}
|
|
178
177
|
|
|
179
|
-
/**
|
|
180
|
-
* Attempt to kill the launched Chrome, if defined.
|
|
181
|
-
* @param {ChromeLauncher.LaunchedChrome=} launchedChrome
|
|
182
|
-
* @return {Promise<void>}
|
|
183
|
-
*/
|
|
184
|
-
async function potentiallyKillChrome(launchedChrome) {
|
|
185
|
-
if (!launchedChrome) return;
|
|
186
|
-
|
|
187
|
-
/** @type {NodeJS.Timeout} */
|
|
188
|
-
let timeout;
|
|
189
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
190
|
-
timeout = setTimeout(reject, 5000, new Error('Timed out waiting to kill Chrome'));
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
return Promise.race([
|
|
194
|
-
launchedChrome.kill(),
|
|
195
|
-
timeoutPromise,
|
|
196
|
-
]).catch(async err => {
|
|
197
|
-
const runningProcesses = await psList();
|
|
198
|
-
if (!runningProcesses.some(proc => proc.pid === launchedChrome.pid)) {
|
|
199
|
-
log.warn('CLI', 'Warning: Chrome process could not be killed because it already exited.');
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
throw new Error(`Couldn't quit Chrome process. ${err}`);
|
|
204
|
-
}).finally(() => {
|
|
205
|
-
clearTimeout(timeout);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
178
|
/**
|
|
210
179
|
* @param {string} url
|
|
211
180
|
* @param {LH.CliFlags} flags
|
|
@@ -214,12 +183,10 @@ async function potentiallyKillChrome(launchedChrome) {
|
|
|
214
183
|
*/
|
|
215
184
|
async function runLighthouse(url, flags, config) {
|
|
216
185
|
/** @param {any} reason */
|
|
217
|
-
|
|
186
|
+
function handleTheUnhandled(reason) {
|
|
218
187
|
process.stderr.write(`Unhandled Rejection. Reason: ${reason}\n`);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
process.exit(1);
|
|
222
|
-
}, 100);
|
|
188
|
+
launchedChrome?.kill();
|
|
189
|
+
process.exit(1);
|
|
223
190
|
}
|
|
224
191
|
process.on('unhandledRejection', handleTheUnhandled);
|
|
225
192
|
|
|
@@ -247,7 +214,7 @@ async function runLighthouse(url, flags, config) {
|
|
|
247
214
|
await saveResults(runnerResult, flags);
|
|
248
215
|
}
|
|
249
216
|
|
|
250
|
-
|
|
217
|
+
launchedChrome?.kill();
|
|
251
218
|
process.removeListener('unhandledRejection', handleTheUnhandled);
|
|
252
219
|
|
|
253
220
|
// Runtime errors indicate something was *very* wrong with the page result.
|
|
@@ -265,7 +232,7 @@ async function runLighthouse(url, flags, config) {
|
|
|
265
232
|
|
|
266
233
|
return runnerResult;
|
|
267
234
|
} catch (err) {
|
|
268
|
-
|
|
235
|
+
launchedChrome?.kill();
|
|
269
236
|
return printErrorAndExit(err);
|
|
270
237
|
}
|
|
271
238
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "12.0.0-dev.
|
|
4
|
+
"version": "12.0.0-dev.20240514",
|
|
5
5
|
"description": "Automated auditing, performance metrics, and best practices for the web.",
|
|
6
6
|
"main": "./core/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -198,7 +198,6 @@
|
|
|
198
198
|
"metaviewport-parser": "0.3.0",
|
|
199
199
|
"open": "^8.4.0",
|
|
200
200
|
"parse-cache-control": "1.0.1",
|
|
201
|
-
"ps-list": "^8.0.0",
|
|
202
201
|
"puppeteer-core": "^22.6.5",
|
|
203
202
|
"robots-parser": "^3.0.1",
|
|
204
203
|
"semver": "^5.3.0",
|