Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to "lighthouse": "^11.3.0", #960

Conversation

hamirmahal
Copy link

fixes #959.

Copy link

google-cla bot commented Nov 3, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@@ -59,7 +59,7 @@ function determineChromePath(options) {
process.env.CHROME_PATH ||
PuppeteerManager.getChromiumPath(options) ||
getChromeInstallationsSafe()[0] ||
undefined
'/usr/bin/chromium-browser'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning to undo this change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm leaving this in the draft PR so the maintainers can tell me the idiomatic way to set this environment variable.

"id": "largest-contentful-paint",
"title": "Largest Contentful Paint"
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually failed to run locally.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$  yarn start collect --url https://www.coursehero.com/ --output=json > ./packages/server/test/fixtures/lh-11-3-0-coursehero-a.json
Error: Lighthouse failed with exit code 1
    at ChildProcess.<anonymous> (/home/hamir/lighthouse-ci/packages/cli/src/collect/node-runner.js:120:21)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
{
  "lighthouseVersion": "11.3.0",
  "requestedUrl": "https://www.coursehero.com/",
  "mainDocumentUrl": "https://www.coursehero.com/",
  "finalDisplayedUrl": "https://www.coursehero.com/",
  "finalUrl": "https://www.coursehero.com/",
  "fetchTime": "2023-11-03T09:38:12.869Z",
  "gatherMode": "navigation",
  "runtimeError": {
    "code": "NO_FCP",
    "message": "The page did not paint any content. Please ensure you keep the browser window in the foreground during the load and try again. (NO_FCP)"
  },
  "runWarnings": [],
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/119.0.6045.105 Safari/537.36",
  "environment": {
    "networkUserAgent": "Mozilla/5.0 (Linux; Android 11; moto g power (2022)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Mobile Safari/537.36",
    "hostUserAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/119.0.6045.105 Safari/537.36",
    "benchmarkIndex": 1990,
    "credits": {
      "axe-core": "4.8.2"
    }
  },
  "audits": {
    "is-on-https": {
      "id": "is-on-https",
      "title": "Uses HTTPS",
      "description": "All sites should be protected with HTTPS, even ones that don't handle sensitive data. This includes avoiding [mixed content](https://developers.google.com/web/fundamentals/security/prevent-mixed-content/what-is-mixed-content), where some resources are loaded over HTTP despite the initial request being served over HTTPS. HTTPS prevents intruders from tampering with or passively listening in on the communications between your app and your users, and is a prerequisite for HTTP/2 and many new web platform APIs. [Learn more about HTTPS](https://developer.chrome.com/docs/lighthouse/pwa/is-on-https/).",
      "score": 1,
      "scoreDisplayMode": "binary",
      "details": {
        "type": "table",
        "headings": [],
        "items": []
      }
    },
    "viewport": {
      "id": "viewport",
      "title": "Has a `<meta name=\"viewport\">` tag with `width` or `initial-scale`",
      "description": "A `<meta name=\"viewport\">` not only optimizes your app for mobile screen sizes, but also prevents [a 300 millisecond delay to user input](https://developer.chrome.com/blog/300ms-tap-delay-gone-away/). [Learn more about using the viewport meta tag](https://developer.chrome.com/docs/lighthouse/pwa/viewport/).",
      "score": 1,
      "scoreDisplayMode": "metricSavings",
      "warnings": [],
      "metricSavings": {
        "INP": 0
      },
      "guidanceLevel": 3
    },
    "first-contentful-paint": {
      "id": "first-contentful-paint",
      "title": "First Contentful Paint",
      "description": "First Contentful Paint marks the time at which the first text or image is painted. [Learn more about the First Contentful Paint metric](https://developer.chrome.com/docs/lighthouse/performance/first-contentful-paint/).",
      "score": null,
      "scoreDisplayMode": "error",
      "errorMessage": "The page did not paint any content. Please ensure you keep the browser window in the foreground during the load and try again. (NO_FCP)",
      "errorStack": "LighthouseError: NO_FCP\n    at LHTraceProcessor.createNoFirstContentfulPaintError (file:///home/hamir/lighthouse-ci/node_modules/lighthouse/core/lib/lh-trace-processor.js:41:12)\n    at LHTraceProcessor.computeNavigationTimingsForFrame (file:///home/hamir/lighthouse-ci/node_modules/lighthouse/core/lib/tracehouse/trace-processor.js:957:18)\n    at LHTraceProcessor.processNavigation (file:///home/hamir/lighthouse-ci/node_modules/lighthouse/core/lib/tracehouse/trace-processor.js:800:31)\n    at ProcessedNavigation.compute_ (file:///home/hamir/lighthouse-ci/node_modules/lighthouse/core/computed/processed-navigation.js:32:29)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
    },
    "largest-contentful-paint": {
      "id": "largest-contentful-paint",
      "title": "Largest Contentful Paint",
      "

is where the json output originally ended.

Comment on lines +70 to +75
console.log('newCssText', newCssText);
console.log('typeof newCssText', typeof newCssText);
console.log('typeof newCssText.replaceAll', typeof newCssText.replaceAll);
const regex = /url\(.\assets/g;
const next = newCssText.replace(regex, `url(../assets`);
fs.writeFileSync(cssDistPath, next);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to do all of this because I'd otherwise get

$  yarn build
yarn run v1.22.19
$ lerna run --scope @lhci/server --scope @lhci/viewer build
lerna notice cli v3.22.0
lerna notice filter including ["@lhci/server","@lhci/viewer"]
lerna info filter [ '@lhci/server', '@lhci/viewer' ]
lerna info Executing command in 2 packages: "yarn run build"
lerna ERR! yarn run build exited 1 in '@lhci/viewer'
lerna ERR! yarn run build stdout:
$ node ../../scripts/build-app.js build ./src/ui/index.html ./dist ./
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

lerna ERR! yarn run build stderr:
TypeError: fs.readFileSync(...).replaceAll is not a function
    at fixHtmlSubresourceUrls (/home/hamir/lighthouse-ci/scripts/build-app.js:71:6)
    at main (/home/hamir/lighthouse-ci/scripts/build-app.js:112:3)
error Command failed with exit code 1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$  nvm ls
->     v14.21.3

"id": "largest-contentful-paint",
"title": "Largest Contentful Paint"
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also didn't finish properly, which is the primary reason this pull request is in a draft state.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fri, 03 Nov 2023 09:51:54 GMT LH:status Auditing: Structured data is valid
Fri, 03 Nov 2023 09:51:54 GMT LH:status Auditing: Page didn't prevent back/forward cache restoration
Fri, 03 Nov 2023 09:51:54 GMT LH:status Generating results...
Fri, 03 Nov 2023 09:51:54 GMT LH:ChromeLauncher Killing Chrome instance 14404
Runtime error encountered: The page did not paint any content. Please ensure you keep the browser window in the foreground during the load and try again. (NO_FCP)
error Command failed with exit code 1.        

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestions on how to make this work?

@adamraine
Copy link
Member

Thanks for putting this together @hamirmahal, we are definitely behind on updating LHCI to use LH 11.0. Looking through the change list, I think we need GoogleChrome/lighthouse#15597 to ship before proceeding.

@hamirmahal
Copy link
Author

You're welcome @adamraine. Let me know if there are any changes you'd like me to make here in the meantime.

@Francis0121
Copy link

When will it be merged?

@connorjclark
Copy link
Collaborator

#991

@hamirmahal hamirmahal deleted the feat/upgrade-to-lighthouse-11-3 branch December 15, 2023 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

npm install in a repository using "@lhci/cli" shows npm WARN deprecated [email protected]
4 participants