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

Executing lighthouse lic gets stuck in alpine nodejs environment #15793

Open
2 tasks done
ZengTianShengZ opened this issue Feb 1, 2024 · 7 comments
Open
2 tasks done

Comments

@ZengTianShengZ
Copy link

FAQ

URL

https://baidu.com

What happened?

When I execute Lighthouse in the alpine nodejs docker environment, Lighthouse gets stuck. I see in the log that chromium-browser is started normally, but Lighthouse keeps getting stuck and cannot be executed.

 sudo lighthouse  --verbose https://baidu.com  --enable-error-reporting --chrome-flags="--no-sandbox --headless --disable-gpu" --output=json
  LH:ChromeLauncher:verbose created /tmp/lighthouse.A0a1Iw4 +0ms
  LH:ChromeLauncher:verbose Launching with command:
  LH:ChromeLauncher:verbose "/usr/bin/chromium-browser" --disable-features=Translate,OptimizationHints,MediaRouter,DialMediaRouteProvider,CalculateNativeWinOcclusion,InterestFeedContentSuggestions,CertificateTransparencyComponentUpdater,AutofillServerCommunication --disable-extensions --disable-component-extensions-with-background-pages --disable-background-networking --disable-component-update --disable-client-side-phishing-detection --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-default-browser-check --no-first-run --disable-backgrounding-occluded-windows --disable-renderer-backgrounding --disable-background-timer-throttling --disable-ipc-flooding-protection --password-store=basic --use-mock-keychain --force-fieldtrials=*BackgroundTracing/default/ --disable-hang-monitor --disable-prompt-on-repost --disable-domain-reliability --remote-debugging-port=39804 --disable-setuid-sandbox --user-data-dir=/tmp/lighthouse.A0a1Iw4 --no-sandbox --headless --disable-gpu about:blank +5ms
  LH:ChromeLauncher:verbose Chrome running with pid 539 on port 39804. +7ms
  LH:ChromeLauncher Waiting for browser. +1ms
  LH:ChromeLauncher Waiting for browser... +0ms
  LH:ChromeLauncher Waiting for browser..... +506ms
  LH:ChromeLauncher Waiting for browser.....✓ +2ms
  LH:status:verbose Initialize config +1ms
  LH:status:verbose Resolve artifact definitions +3ms
  LH:statusEnd:verbose Resolve artifact definitions +102ms
  LH:statusEnd:verbose Initialize config +834ms
  LH:status:verbose Gather phase +0ms

image

What did you expect?

Lighthouse can execute normally and output results in alpine nodejs docker environment

What have you tried?

No response

How were you running Lighthouse?

CLI, node

Lighthouse Version

11.5.0

Chrome Version

Chromium 112.0.5615.165

Node Version

v18.15.0

OS

Linux

Relevant log output

Specify --help for available options
lighthouse-service-app-d84d67d8f-8r6zm:/app# lighthouse  --version     
11.5.0
lighthouse-service-app-d84d67d8f-8r6zm:/app# node -v
v18.15.0
lighthouse-service-app-d84d67d8f-8r6zm:/app# chromium-browser
[749:749:0201/110558.351580:ERROR:zygote_host_impl_linux.cc(100)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
lighthouse-service-app-d84d67d8f-8r6zm:/app# chromium-browser --version
Chromium 112.0.5615.165 
lighthouse-service-app-d84d67d8f-8r6zm:/app#  sudo lighthouse  --verbose https://baidu.com  --enable-error-reporting --chrome-flags="--no-sandbox --headless --disable-gpu" --output=json
  LH:ChromeLauncher:verbose created /tmp/lighthouse.xpmKgXW +0ms
  LH:ChromeLauncher:verbose Launching with command:
  LH:ChromeLauncher:verbose "/usr/bin/chromium-browser" --disable-features=Translate,OptimizationHints,MediaRouter,DialMediaRouteProvider,CalculateNativeWinOcclusion,InterestFeedContentSuggestions,CertificateTransparencyComponentUpdater,AutofillServerCommunication --disable-extensions --disable-component-extensions-with-background-pages --disable-background-networking --disable-component-update --disable-client-side-phishing-detection --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-default-browser-check --no-first-run --disable-backgrounding-occluded-windows --disable-renderer-backgrounding --disable-background-timer-throttling --disable-ipc-flooding-protection --password-store=basic --use-mock-keychain --force-fieldtrials=*BackgroundTracing/default/ --disable-hang-monitor --disable-prompt-on-repost --disable-domain-reliability --remote-debugging-port=35116 --disable-setuid-sandbox --user-data-dir=/tmp/lighthouse.xpmKgXW --no-sandbox --headless --disable-gpu about:blank +11ms
  LH:ChromeLauncher:verbose Chrome running with pid 782 on port 35116. +7ms
  LH:ChromeLauncher Waiting for browser. +1ms
  LH:ChromeLauncher Waiting for browser... +0ms
  LH:ChromeLauncher Waiting for browser..... +506ms
  LH:ChromeLauncher Waiting for browser.....✓ +2ms
  LH:status:verbose Initialize config +1ms
  LH:status:verbose Resolve artifact definitions +2ms
  LH:statusEnd:verbose Resolve artifact definitions +100ms
  LH:statusEnd:verbose Initialize config +792ms
  LH:status:verbose Gather phase +1ms
@adamraine
Copy link
Member

Does adding --disable-dev-shm-usage to the chrome flags fix the issue for you?

https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#tips

@ZengTianShengZ
Copy link
Author

Does adding --disable-dev-shm-usage to the chrome flags fix the issue for you?

https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#tips

I retest and get the same results.

lighthouse-service-app-d84d67d8f-8r6zm:/app# sudo lighthouse  --verbose https://baidu.com  --enable-error-reporting --disable-dev-shm-usage --chrome-flags="--no-sandbox --headless --disable-gpu" --output=json
  LH:ChromeLauncher:verbose created /tmp/lighthouse.uD3FcQQ +0ms
  LH:ChromeLauncher:verbose Launching with command:
  LH:ChromeLauncher:verbose "/usr/bin/chromium-browser" --disable-features=Translate,OptimizationHints,MediaRouter,DialMediaRouteProvider,CalculateNativeWinOcclusion,InterestFeedContentSuggestions,CertificateTransparencyComponentUpdater,AutofillServerCommunication --disable-extensions --disable-component-extensions-with-background-pages --disable-background-networking --disable-component-update --disable-client-side-phishing-detection --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-default-browser-check --no-first-run --disable-backgrounding-occluded-windows --disable-renderer-backgrounding --disable-background-timer-throttling --disable-ipc-flooding-protection --password-store=basic --use-mock-keychain --force-fieldtrials=*BackgroundTracing/default/ --disable-hang-monitor --disable-prompt-on-repost --disable-domain-reliability --remote-debugging-port=40237 --disable-setuid-sandbox --user-data-dir=/tmp/lighthouse.uD3FcQQ --no-sandbox --headless --disable-gpu about:blank +5ms
  LH:ChromeLauncher:verbose Chrome running with pid 1902 on port 40237. +8ms
  LH:ChromeLauncher Waiting for browser. +0ms
  LH:ChromeLauncher Waiting for browser... +0ms
  LH:ChromeLauncher Waiting for browser..... +507ms
  LH:ChromeLauncher Waiting for browser.....✓ +1ms
  LH:status:verbose Initialize config +1ms
  LH:status:verbose Resolve artifact definitions +3ms
  LH:statusEnd:verbose Resolve artifact definitions +104ms
  LH:statusEnd:verbose Initialize config +826ms
  LH:status:verbose Gather phase +0ms

@adamraine
Copy link
Member

You need to add it to --chrome-flags:

udo lighthouse  --verbose https://baidu.com/  --enable-error-reporting --chrome-flags="--disable-dev-shm-usage --no-sandbox --headless --disable-gpu" --output=json

@ZengTianShengZ
Copy link
Author

I readjusted the test command, but it still stuck.

image

@Miindaugas
Copy link

Miindaugas commented Mar 11, 2024

I tried run in on alpine node:21.7.0-alpine3.19 to generate reports for my nextjs applicaiton.

--disable-dev-shm-usage did help. Thank you.

✅ npx lighthouse http://localhost:8080 --chrome-flags="--headless --disable-dev-shm-usage"

lhci lighthouserc.json

{
  "ci": {
    "collect": {
      "startServerCommand": "npm start",
      "settings": {
         "chromeFlags": "--headless --disable-dev-shm-usage",
       },
      "url": ["http://localhost:8080"]
    }
  }
}
FROM node:21.7.0-alpine3.19 AS test

ENV APP_ENV development
ENV NODE_ENV development
ENV NEXT_TELEMETRY_DISABLED 1

RUN apk add chromium

RUN mkdir /app
RUN mkdir /source

RUN addgroup --system --gid 1001 app-users
RUN adduser -D --system --uid 1001 --home /app app-user app-users
RUN chown -R app-user:app-users /app
RUN chown -R app-user:app-users /source

WORKDIR /app

COPY --from=build_test --chown=app-user:app-users /source /source
COPY --from=build_test --chown=app-user:app-users /source/public ./public
COPY --from=build_test --chown=app-user:app-users /source/.next/standalone ./
COPY --from=build_test --chown=app-user:app-users /source/.next/static ./.next/static

USER app-user

EXPOSE 8080
ENV PORT 8080
ENV HOSTNAME 0.0.0.0

@dillonbarker-te
Copy link

dillonbarker-te commented Mar 21, 2024

In our case,

Adding --headless will make it work, but we need it to be headless false.

So --headless is what fixes it, not the --disable-dev-shm-usage

My output is below

npx lighthouse "https://www.google.com" --verbose --output=json ----disable-storage-reset --output=html --output-path='test.html' --port=8041 ----screenEmulation.disabled ----preset desktop

 LH:ChromeLauncher Found existing Chrome already running using port 8041, using that. +0ms
 LH:status:verbose Initialize config +2ms
 LH:status:verbose Resolve artifact definitions +2ms
 LH:statusEnd:verbose Resolve artifact definitions +83ms
 LH:statusEnd:verbose Initialize config +481ms
 LH:status:verbose Gather phase +1ms

We see after 10 minutes we get

LH:status Connecting to browser +10m`

node: v20.11.1
lighthouse: 11.7.0
puppeteer: 22.6.0

We occasionally when escaping the command will see the same log as shown in this puppeteer log.

puppeteer/puppeteer#7807

@ZengTianShengZ
Copy link
Author

Is there any progress on this issue? I still cannot run Lighthouse normally in my scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants