GoogleChrome / lighthouse

Automated auditing, performance metrics, and best practices for the web.
https://developer.chrome.com/docs/lighthouse/overview/
Apache License 2.0
28.32k stars 9.36k forks source link

Didn't work in CICD #14076

Open rainydayDY opened 2 years ago

rainydayDY commented 2 years ago

FAQ

URL

https://git.n.xiaomi.com/appstore-frontend/appstore-mobile/-/jobs/7951614

What happened?

I run it correctly locally, but when I run gitlab ci, I get an error。The error message is as follows:

(node:100) UnhandledPromiseRejectionWarning: Error
    at new LauncherError (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/utils.js:26:22)
    at new ChromePathNotSetError (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/utils.js:33:9)
    at Object.linux (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/chrome-finder.js:128:15)
    at Function.getFirstInstallation (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/chrome-launcher.js:126:51)
    at Launcher.launch (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/chrome-launcher.js:185:43)
    at Object.launch (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/chrome-launcher.js:37:20)
    at /builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/build/performance/lighthouse.js:46:39
    at Object.<anonymous> (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/build/performance/lighthouse.js:108:3)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

What did you expect?

run collectly with gitlab ci, I want to run performance when deploy pages

What have you tried?

nothing

How were you running Lighthouse?

CLI

Lighthouse Version

9.6.1

Chrome Version

No response

Node Version

14.17.3

OS

Mac

Relevant log output

(node:100) UnhandledPromiseRejectionWarning: Error
    at new LauncherError (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/utils.js:26:22)
    at new ChromePathNotSetError (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/utils.js:33:9)
    at Object.linux (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/chrome-finder.js:128:15)
    at Function.getFirstInstallation (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/chrome-launcher.js:126:51)
    at Launcher.launch (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/chrome-launcher.js:185:43)
    at Object.launch (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/node_modules/chrome-launcher/dist/chrome-launcher.js:37:20)
    at /builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/build/performance/lighthouse.js:46:39
    at Object.<anonymous> (/builds/FoU-rNW-/0/appstore-frontend/appstore-mobile/build/performance/lighthouse.js:108:3)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
adamraine commented 2 years ago

https://git.n.xiaomi.com/appstore-frontend/appstore-mobile/-/jobs/7951614 isn't working for me, do you have another URL?

rainydayDY commented 2 years ago

I don't think this access link is important. What really matters is the error message that follows. I hope to run lighthouse in cicd, but it doesn't work. I guess it's because there is a problem with starting chrome, because there is no chrome available in cicd? So what should I do?

connorjclark commented 2 years ago

Yes, you need chrome installed.

@paulirish any idea why the error message here is non-existent? Whatever this error pattern is, it doesn't seem to result in an error message https://github.com/GoogleChrome/chrome-launcher/blob/ff91c18bdf12b142d6f21f8ed5fd81e9835aae82/src/utils.ts#L36

rainydayDY commented 2 years ago

how can I run lighthouse in Docker?I find an answer https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker, Can this be used? I want to use lighthouse in CICD, how should I set it up?

paulirish commented 2 years ago

@rainydayDY the callstack indicates chrome-launcher cannot find a chrome installation in the linux OS. you can either have one in a typical location or use the CHROME_PATH environment variable to point to one. i guess your docker image doesnt have chrome?

it's a bug that we don't provide a proper error message, though !

rainydayDY commented 2 years ago

I added a chrome image to docker, and new problems occurred after running (node:91) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:42697 [318](https://git.n.xiaomi.com/appstore-frontend/appstore-mobile/-/jobs/7969622#L318) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) [319](https://git.n.xiaomi.com/appstore-frontend/appstore-mobile/-/jobs/7969622#L319)(Usenode --trace-warnings ...to show where the warning was created) [320](https://git.n.xiaomi.com/appstore-frontend/appstore-mobile/-/jobs/7969622#L320)(node:91) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) [321](https://git.n.xiaomi.com/appstore-frontend/appstore-mobile/-/jobs/7969622#L321)(node:91) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. There was no problem with mirroring, it was later solved by adding --no-sandbox const chrome = await chromeLauncher.launch({ chromeFlags: ['--headless', '--no-sandbox'], }); Thank you so much and good luck~