lighthouse-ci-action icon indicating copy to clipboard operation
lighthouse-ci-action copied to clipboard

Lighthouse CI Hanging in GitHub Actions — Then Fails with screenEmulation Error

Open hiro-daikin opened this issue 8 months ago • 2 comments

Summary: Lighthouse CI recently started timing out in our GitHub Actions pipeline with no changes to the pipeline, Lighthouse config, or application code.

To debug, I switched to using @lhci/cli directly, and it printed the following error:

Error: Screen emulation mobile setting (true) does not match formFactor setting (desktop)

After explicitly setting screenEmulation.mobile = false in the config, Lighthouse began working again.

❓ Unexpected Behavior Even before the above error was visible, the pipeline was hanging and eventually failing silently — no helpful output. This started suddenly and consistently fails, even when I revert to the last known good commit (where Lighthouse was passing before).

It seems like:

Lighthouse silently fails or hangs when screenEmulation.mobile is not explicitly set.

There's now a required match between screenEmulation.mobile and formFactor, but that validation didn’t use to block execution (or cause hangs).

💻 GitHub Actions Snippet

uses: treosh/lighthouse-ci-action@v12
with:
  urls: |
    ${{ vars.BASE_URL }}/app
  configPath: './.lighthouserc.js'
  uploadArtifacts: true
  runs: 3

🧾 Config Snippet (before fix)

ci: {
  collect: {
    puppeteerScript: './lighthouseAuth.js',
    puppeteerLaunchOptions: {
      args: ['--no-sandbox']
    },
    beforeEach: true,
    isSinglePageApplication: true,
    settings: {
      maxWaitForFcp: 15000,
      maxWaitForLoad: 35000,
      formFactor: 'desktop',
      preset: 'desktop',
      throttling: {
        rttMs: 40,
        throughputKbps: 10240,
        cpuSlowdownMultiplier: 1
      },
      skipAudits: ['uses-http2']
    }
  },
  // ...
}

Adding this fixed it:

screenEmulation: {
  mobile: false,
  width: 1350,
  height: 940,
  deviceScaleFactor: 1,
  disabled: false
}

📝 Request Should Lighthouse throw a clearer error sooner, especially in CI, if screenEmulation.mobile mismatches formFactor?

Why did this suddenly start breaking? Is this from a recent Lighthouse version bump or CLI change?

Thanks in advance!

hiro-daikin avatar May 09 '25 22:05 hiro-daikin

Can confirm the sudden failure on an existing stable pipeline of a complex project that I recently onboarded. 🤦‍♂️ ScreenEmulation fix above didn't work for me. Looking to switch to back to plain @lhci/cli

Keshavdulal avatar May 19 '25 07:05 Keshavdulal

@Keshavdulal My pipeline also started failing again after my initial fix. After running around in circles, I found that downloading a different chrome browser works. I'm not sure what pipeline solution you use, but here is more or less the Github Pipelines workflow we have:

      - name: Install chrome and set path
        run: |
          CHROME_PATH=$(npx @puppeteer/browsers install chrome@latest | awk '{print $2}')
          echo "CHROME_PATH=$CHROME_PATH" >> $GITHUB_ENV

      - name: Run Lighthouse on urls and validate with lighthouserc
        uses: treosh/lighthouse-ci-action@v12
        env:
          CHROME_PATH: ${{ env.CHROME_PATH }}

hiro-daikin avatar May 19 '25 17:05 hiro-daikin