lighthouse 11.2.0-dev.20231019 → 11.2.0-dev.20231021

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.
@@ -24,7 +24,7 @@ export function getYargsParser(manualArgv?: string | undefined): yargs.Argv<yarg
24
24
  default: boolean;
25
25
  describe: string;
26
26
  };
27
- }>, "port" | "screenEmulation" | "emulatedUserAgent" | "hostname" | "preset" | "save-assets" | "list-all-audits" | "list-locales" | "list-trace-categories" | "debug-navigation" | "additional-trace-categories" | "config-path" | "chrome-flags" | "form-factor" | "max-wait-for-load" | "enable-error-reporting" | "gather-mode" | "audit-mode" | "only-audits" | "only-categories" | "skip-audits" | "budget-path" | "disable-full-page-screenshot"> & yargs.InferredOptionTypes<{
27
+ }>, "port" | "screenEmulation" | "emulatedUserAgent" | "hostname" | "preset" | "save-assets" | "list-all-audits" | "list-locales" | "list-trace-categories" | "debug-navigation" | "additional-trace-categories" | "config-path" | "chrome-flags" | "form-factor" | "max-wait-for-load" | "enable-error-reporting" | "gather-mode" | "audit-mode" | "only-audits" | "only-categories" | "skip-audits" | "budget-path" | "disable-full-page-screenshot" | "ignore-status-code"> & yargs.InferredOptionTypes<{
28
28
  'save-assets': {
29
29
  type: "boolean";
30
30
  default: boolean;
@@ -133,6 +133,10 @@ export function getYargsParser(manualArgv?: string | undefined): yargs.Argv<yarg
133
133
  type: "boolean";
134
134
  describe: string;
135
135
  };
136
+ 'ignore-status-code': {
137
+ type: "boolean";
138
+ describe: string;
139
+ };
136
140
  }>, "output" | "view" | "output-path"> & yargs.InferredOptionTypes<{
137
141
  output: {
138
142
  type: "array";
package/cli/cli-flags.js CHANGED
@@ -204,12 +204,16 @@ function getYargsParser(manualArgv) {
204
204
  type: 'boolean',
205
205
  describe: 'Disables collection of the full page screenshot, which can be quite large',
206
206
  },
207
+ 'ignore-status-code': {
208
+ type: 'boolean',
209
+ describe: 'Disables failing on all error status codes, and instead issues a warning.',
210
+ },
207
211
  })
208
212
  .group([
209
213
  'save-assets', 'list-all-audits', 'list-locales', 'list-trace-categories', 'additional-trace-categories',
210
214
  'config-path', 'preset', 'chrome-flags', 'port', 'hostname', 'form-factor', 'screenEmulation', 'emulatedUserAgent',
211
215
  'max-wait-for-load', 'enable-error-reporting', 'gather-mode', 'audit-mode',
212
- 'only-audits', 'only-categories', 'skip-audits', 'budget-path', 'disable-full-page-screenshot',
216
+ 'only-audits', 'only-categories', 'skip-audits', 'budget-path', 'disable-full-page-screenshot', 'ignore-status-code',
213
217
  ], 'Configuration:')
214
218
 
215
219
  // Output
@@ -113,6 +113,7 @@ const defaultSettings = {
113
113
  disableFullPageScreenshot: false,
114
114
  skipAboutBlank: false,
115
115
  blankPage: 'about:blank',
116
+ ignoreStatusCode: false,
116
117
 
117
118
  // the following settings have no defaults but we still want ensure that `key in settings`
118
119
  // in config will work in a typechecked way
@@ -155,6 +155,7 @@ async function _computeNavigationResult(
155
155
  const pageLoadError = debugData.records
156
156
  ? getPageLoadError(navigationError, {
157
157
  url: mainDocumentUrl,
158
+ ignoreStatusCode: navigationContext.resolvedConfig.settings.ignoreStatusCode,
158
159
  networkRecords: debugData.records,
159
160
  warnings: navigationContext.baseArtifacts.LighthouseRunWarnings,
160
161
  })
@@ -1,9 +1,13 @@
1
1
  /**
2
2
  * Returns an error if the original network request failed or wasn't found.
3
3
  * @param {LH.Artifacts.NetworkRequest|undefined} mainRecord
4
+ * @param {{warnings: Array<string | LH.IcuMessage>, ignoreStatusCode?: LH.Config.Settings['ignoreStatusCode']}} context
4
5
  * @return {LH.LighthouseError|undefined}
5
6
  */
6
- export function getNetworkError(mainRecord: LH.Artifacts.NetworkRequest | undefined): LH.LighthouseError | undefined;
7
+ export function getNetworkError(mainRecord: LH.Artifacts.NetworkRequest | undefined, context: {
8
+ warnings: Array<string | LH.IcuMessage>;
9
+ ignoreStatusCode?: LH.Config.Settings['ignoreStatusCode'];
10
+ }): LH.LighthouseError | undefined;
7
11
  /**
8
12
  * Returns an error if we ended up on the `chrome-error` page and all other requests failed.
9
13
  * @param {LH.Artifacts.NetworkRequest|undefined} mainRecord
@@ -15,11 +19,12 @@ export function getInterstitialError(mainRecord: LH.Artifacts.NetworkRequest | u
15
19
  * Returns an error if the page load should be considered failed, e.g. from a
16
20
  * main document request failure, a security issue, etc.
17
21
  * @param {LH.LighthouseError|undefined} navigationError
18
- * @param {{url: string, networkRecords: Array<LH.Artifacts.NetworkRequest>, warnings: Array<string | LH.IcuMessage>}} context
22
+ * @param {{url: string, ignoreStatusCode?: LH.Config.Settings['ignoreStatusCode'], networkRecords: Array<LH.Artifacts.NetworkRequest>, warnings: Array<string | LH.IcuMessage>}} context
19
23
  * @return {LH.LighthouseError|undefined}
20
24
  */
21
25
  export function getPageLoadError(navigationError: LH.LighthouseError | undefined, context: {
22
26
  url: string;
27
+ ignoreStatusCode?: boolean | undefined;
23
28
  networkRecords: Array<LH.Artifacts.NetworkRequest>;
24
29
  warnings: Array<string | LH.IcuMessage>;
25
30
  }): LH.LighthouseError | undefined;
@@ -32,6 +37,7 @@ export function getPageLoadError(navigationError: LH.LighthouseError | undefined
32
37
  export function getNonHtmlError(finalRecord: LH.Artifacts.NetworkRequest | undefined): LH.LighthouseError | undefined;
33
38
  export namespace UIStrings {
34
39
  const warningXhtml: string;
40
+ const warningStatusCode: string;
35
41
  }
36
42
  import { NetworkRequest } from './network-request.js';
37
43
  import { LighthouseError } from './lh-error.js';
@@ -16,6 +16,13 @@ const UIStrings = {
16
16
  */
17
17
  warningXhtml:
18
18
  'The page MIME type is XHTML: Lighthouse does not explicitly support this document type',
19
+ /**
20
+ * @description Warning shown in report when the page under test returns an error code, which Lighthouse is not able to reliably load so we display a warning.
21
+ * @example {404} errorCode
22
+ */
23
+ warningStatusCode: 'Lighthouse was unable to reliably load the page you requested. Make sure' +
24
+ ' you are testing the correct URL and that the server is properly responding' +
25
+ ' to all requests. (Status code: {errorCode})',
19
26
  };
20
27
 
21
28
  const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
@@ -27,9 +34,10 @@ const XHTML_MIME_TYPE = 'application/xhtml+xml';
27
34
  /**
28
35
  * Returns an error if the original network request failed or wasn't found.
29
36
  * @param {LH.Artifacts.NetworkRequest|undefined} mainRecord
37
+ * @param {{warnings: Array<string | LH.IcuMessage>, ignoreStatusCode?: LH.Config.Settings['ignoreStatusCode']}} context
30
38
  * @return {LH.LighthouseError|undefined}
31
39
  */
32
- function getNetworkError(mainRecord) {
40
+ function getNetworkError(mainRecord, context) {
33
41
  if (!mainRecord) {
34
42
  return new LighthouseError(LighthouseError.errors.NO_DOCUMENT_REQUEST);
35
43
  } else if (mainRecord.failed) {
@@ -47,9 +55,13 @@ function getNetworkError(mainRecord) {
47
55
  LighthouseError.errors.FAILED_DOCUMENT_REQUEST, {errorDetails: netErr});
48
56
  }
49
57
  } else if (mainRecord.hasErrorStatusCode()) {
50
- return new LighthouseError(LighthouseError.errors.ERRORED_DOCUMENT_REQUEST, {
51
- statusCode: `${mainRecord.statusCode}`,
52
- });
58
+ if (context.ignoreStatusCode) {
59
+ context.warnings.push(str_(UIStrings.warningStatusCode, {errorCode: mainRecord.statusCode}));
60
+ } else {
61
+ return new LighthouseError(LighthouseError.errors.ERRORED_DOCUMENT_REQUEST, {
62
+ statusCode: `${mainRecord.statusCode}`,
63
+ });
64
+ }
53
65
  }
54
66
  }
55
67
 
@@ -113,7 +125,7 @@ function getNonHtmlError(finalRecord) {
113
125
  * Returns an error if the page load should be considered failed, e.g. from a
114
126
  * main document request failure, a security issue, etc.
115
127
  * @param {LH.LighthouseError|undefined} navigationError
116
- * @param {{url: string, networkRecords: Array<LH.Artifacts.NetworkRequest>, warnings: Array<string | LH.IcuMessage>}} context
128
+ * @param {{url: string, ignoreStatusCode?: LH.Config.Settings['ignoreStatusCode'], networkRecords: Array<LH.Artifacts.NetworkRequest>, warnings: Array<string | LH.IcuMessage>}} context
117
129
  * @return {LH.LighthouseError|undefined}
118
130
  */
119
131
  function getPageLoadError(navigationError, context) {
@@ -144,7 +156,7 @@ function getPageLoadError(navigationError, context) {
144
156
  context.warnings.push(str_(UIStrings.warningXhtml));
145
157
  }
146
158
 
147
- const networkError = getNetworkError(mainRecord);
159
+ const networkError = getNetworkError(mainRecord, context);
148
160
  const interstitialError = getInterstitialError(mainRecord, networkRecords);
149
161
  const nonHtmlError = getNonHtmlError(finalRecord);
150
162
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "11.2.0-dev.20231019",
4
+ "version": "11.2.0-dev.20231021",
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.3.6",
169
+ "puppeteer": "^21.4.0",
170
170
  "resolve": "^1.22.1",
171
171
  "rollup": "^2.52.7",
172
172
  "rollup-plugin-polyfill-node": "^0.12.0",
@@ -199,7 +199,7 @@
199
199
  "open": "^8.4.0",
200
200
  "parse-cache-control": "1.0.1",
201
201
  "ps-list": "^8.0.0",
202
- "puppeteer-core": "^21.3.6",
202
+ "puppeteer-core": "^21.4.0",
203
203
  "robots-parser": "^3.0.1",
204
204
  "semver": "^5.3.0",
205
205
  "speedline-core": "^1.4.3",
@@ -2657,6 +2657,9 @@
2657
2657
  "core/lib/lh-error.js | urlInvalid": {
2658
2658
  "message": "The URL you have provided appears to be invalid."
2659
2659
  },
2660
+ "core/lib/navigation-error.js | warningStatusCode": {
2661
+ "message": "Lighthouse was unable to reliably load the page you requested. Make sure you are testing the correct URL and that the server is properly responding to all requests. (Status code: {errorCode})"
2662
+ },
2660
2663
  "core/lib/navigation-error.js | warningXhtml": {
2661
2664
  "message": "The page MIME type is XHTML: Lighthouse does not explicitly support this document type"
2662
2665
  },
@@ -2657,6 +2657,9 @@
2657
2657
  "core/lib/lh-error.js | urlInvalid": {
2658
2658
  "message": "T̂h́ê ÚR̂Ĺ ŷóû h́âv́ê ṕr̂óv̂íd̂éd̂ áp̂ṕêár̂ś t̂ó b̂é îńv̂ál̂íd̂."
2659
2659
  },
2660
+ "core/lib/navigation-error.js | warningStatusCode": {
2661
+ "message": "L̂íĝh́t̂h́ôúŝé ŵáŝ ún̂áb̂ĺê t́ô ŕêĺîáb̂ĺŷ ĺôád̂ t́ĥé p̂áĝé ŷóû ŕêq́ûéŝt́êd́. M̂ák̂é ŝúr̂é ŷóû ár̂é t̂éŝt́îńĝ t́ĥé ĉór̂ŕêćt̂ ÚR̂Ĺ âńd̂ t́ĥát̂ t́ĥé ŝér̂v́êŕ îś p̂ŕôṕêŕl̂ý r̂éŝṕôńd̂ín̂ǵ t̂ó âĺl̂ ŕêq́ûéŝt́ŝ. (Śt̂át̂úŝ ćôd́ê: {errorCode})"
2662
+ },
2660
2663
  "core/lib/navigation-error.js | warningXhtml": {
2661
2664
  "message": "T̂h́ê ṕâǵê ḾÎḾÊ t́ŷṕê íŝ X́ĤT́M̂Ĺ: L̂íĝh́t̂h́ôúŝé d̂óêś n̂ót̂ éx̂ṕl̂íĉít̂ĺŷ śûṕp̂ór̂t́ t̂h́îś d̂óĉúm̂én̂t́ t̂ýp̂é"
2662
2665
  },
@@ -25,5 +25,9 @@ declare module 'rxjs' {
25
25
  export const delay: any;
26
26
  export const startWith: any;
27
27
  export const switchMap: any;
28
+ export const bufferCount: any;
29
+ export const concatMap: any;
30
+ export const lastValueFrom: any;
31
+ export const takeUntil: any;
28
32
  }
29
33
 
@@ -114,6 +114,9 @@ export type ScreenEmulationSettings = {
114
114
  blankPage?: string;
115
115
  /** Disables collection of the full page screenshot, which can be rather large and possibly leave the page in an undesirable state. */
116
116
  disableFullPageScreenshot?: boolean;
117
+
118
+ /** Disables failing on 404 status code, and instead issues a warning */
119
+ ignoreStatusCode?: boolean;
117
120
  }
118
121
 
119
122
  export interface ConfigSettings extends Required<SharedFlagsSettings> {