GoogleChrome / lighthouse-ci

Automate running Lighthouse for every commit, viewing the changes, and preventing regressions
Apache License 2.0
6.41k stars 643 forks source link

gitlab ci blocks during run #1031

Open chenfan0 opened 5 months ago

chenfan0 commented 5 months ago

lighthouserc.js

module.exports = {
    ci: {
        collect: {
            url: [
                'http://127.0.0.1:8089/'
            ],
            numberOfRuns: 3,
            startServerCommand: "PORT=8089 node src/server",
            settings: {
                hostname: '127.0.0.1',
                chromeFlags: ['--no-sandbox'],
            },
        },
        upload: {
            target: 'temporary-public-storage',
        }
    }
}

.gitlab-ci.yml

lhci:
  stage: test
  image: cypress/browsers:node-18.16.1-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1
  script:   
    - npm install
    - npm install -g @lhci/cli@0.13.x
    - npm run build
    - lhci autorun --config=./lighthouserc.js || echo "LHCI failed!"
image
ydhnwb commented 5 months ago

I also got this. Any solution?

njsaunders commented 4 months ago

Has the npm package been compromised?

$ npx lhci --version
Hello, this is AnupamAS01!
chenfan0 commented 4 months ago

I also got this. Any solution?

no 😞

lukaas33 commented 4 months ago

I have the same issue with the following CI config:

lighthouse:
  stage: .pre
  image: cypress/browsers:node16.17.0-chrome106
  script:
    - npm install -g @lhci/cli@0.13.x
    - lhci autorun --upload.target=temporary-public-storage --collect.settings.chromeFlags="--no-sandbox" --collect.staticDistDir="wiki/pages" --collect.numberOfRuns=1 || echo "LHCI failed!"
chenfan0 commented 3 months ago

I found a solution. I executed this download-chrome.sh to install Chrome, and then set the environment variable LIGHTHOUSE_CHROMIUM_PATH to the location of Chrome downloaded by the script, and then it can run normally.

ArgV04 commented 3 months ago

Any news on this? I am also facing this kind of issue

chenfan0 commented 3 months ago

Any news on this? I am also facing this kind of issue

I found a solution. I executed this download-chrome.sh to install Chrome, and then set the environment variable LIGHTHOUSE_CHROMIUM_PATH to the location of Chrome downloaded by the script, and then it can run normally.

here

ArgV04 commented 3 months ago

Any news on this? I am also facing this kind of issue

I found a solution. I executed this download-chrome.sh to install Chrome, and then set the environment variable LIGHTHOUSE_CHROMIUM_PATH to the location of Chrome downloaded by the script, and then it can run normally.

here

How does it work? The script already checks for LIGHTHOUSE_CHROMIUM_PATH and exit if not exist. And what the value of LIGHTHOUSE_CHROMIUM_PATH ... I tried this script partially ... meaning downloading chrome .... and execute wget ... but with this ... its still not working

njsaunders commented 1 month ago

Manage to "Fix" this by using Node 22 and setting the following flag:

export NODE_OPTIONS="--max-old-space-size=7168"
njsaunders commented 1 month ago

Turns out that was only for one pipeline. It's happening again. Have opened https://github.com/GoogleChrome/lighthouse-ci/pull/1070 to figure out whats going on. Not giving up on this one!

njsaunders commented 1 month ago

With debugging turned on looks like it's blocking connecting to Chrome:

Mon, 02 Sep 2024 12:13:45 GMT LH:status Auditing: Document has a valid `rel=canonical`
Mon, 02 Sep 2024 12:13:45 GMT LH:status Auditing: Structured data is valid
Mon, 02 Sep 2024 12:13:45 GMT LH:status Auditing: Page didn't prevent back/forward cache restoration
Mon, 02 Sep 2024 12:13:45 GMT LH:status Generating results...
done.
Run #3...Mon, 02 Sep 2024 12:13:46 GMT LH:ChromeLauncher Found existing Chrome already running using port 41471, using that.

Just sits there waiting at that. Debugging continues.

njsaunders commented 1 month ago

Ok - I don't know why but this is related to the version of Chrome used. I downgraded from 128 to 127 and everything started working fine again.

alexislefebvre commented 2 weeks ago

We faced the same issue, we fixed it by using a newer version of the container, it has updates of node and Chrome, so we don't know the root cause.

This never ends:

docker run --rm -it cypress/browsers:node-20.5.0-chrome-114.0.5735.133-1-ff-114.0.2-edge-114.0.1823.51-1 \
bash -c 'yarn global add @lhci/cli@0.14.x ; lhci collect --url https://www.google.com \
--collect.settings.chromeFlags="--no-sandbox"'

This works:

docker run --rm -it cypress/browsers:node-20.17.0-chrome-128.0.6613.119-1-ff-130.0-edge-128.0.2739.63-1 \
bash -c 'yarn global add @lhci/cli@0.14.x ; lhci collect --url https://www.google.com \
--collect.settings.chromeFlags="--no-sandbox"'