Cannot Invoke Chrome browser inside Jenkins.
See original GitHub issueRunning Lighthouse programmatically. It runs well on my local, when trying to invoke this is inside Jenkins. I see the error for chrome launcher.
What is the current behavior?
Running Audit ( 1 of 2 ) for https://www.google.com/ (node:35) UnhandledPromiseRejectionWarning: Error at new LauncherError (/xxxx/jenkins/workspace/-fetching-metrics-for-the-builds/node_modules/chrome-launcher/dist/utils.js:35:22) at new ChromePathNotSetError (/xxxx/jenkins/workspace/-fetching-metrics-for-the-builds/node_modules/chrome-launcher/dist/utils.js:42:9) at Object.linux (/xxxx/jenkins/workspace/-fetching-metrics-for-the-builds/node_modules/chrome-launcher/dist/chrome-finder.js:108:15) at Function.getInstallations (/xxxx/jenkins/workspace/-fetching-metrics-for-the-builds/node_modules/chrome-launcher/dist/chrome-launcher.js:114:51) at Launcher.<anonymous> (/xxxx/jenkins/workspace/-fetching-metrics-for-the-builds/node_modules/chrome-launcher/dist/chrome-launcher.js:147:48) at Generator.next (<anonymous>) at /xxxx/jenkins/workspace/-fetching-metrics-for-the-builds/node_modules/chrome-launcher/dist/chrome-launcher.js:12:71 at new Promise (<anonymous>) at __awaiter (/xxxx/jenkins/workspace/-fetching-metrics-for-the-builds/node_modules/chrome-launcher/dist/chrome-launcher.js:8:12) at Launcher.launch (/xxxx/jenkins/workspace/-fetching-metrics-for-the-builds/node_modules/chrome-launcher/dist/chrome-launcher.js:135:16) (node:35) 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(). (rejection id: 2) (node:35) [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.
My JS file invoking lighthouse.
const lighthouse = require('lighthouse'); const chromeLauncher = require('chrome-launcher'); const configSetting = require('./custom-config.js'); const writeJsonFile = require('write-json-file'); const fs = require('fs'); function launchChromeAndRunLighthouse(url, opts, config = null) { return chromeLauncher.launch({chromeFlags: opts.chromeFlags}).then(chrome => { opts.port = chrome.port; return lighthouse(url, opts, config).then(results => { return chrome.kill().then(() => results.lhr) }); }); } const opts = { chromeFlags: ['--headless'], // chromeFlags: ['--no-sandbox','--headless'], onlyCategories: ['performance', 'pwa'] };
My package .json.
{ "dependencies": { "chrome": "^0.1.0", "chrome-launcher": "^0.12.0", "lighthouse": "^5.6.0", "write-json-file": "^4.2.1" } }
Jenkins file
steps{ sh "npm install" } } stage('run node'){ steps{ sh "node index.js" } }
Environment Information
- Affected Channels:
- Lighthouse version: 5.6
- Chrome-launcher version:0.12
- Node.js version: 10.17
- Operating System: Jenkins.
Related issues
Issue Analytics
- State:
- Created 4 years ago
- Comments:11
Top GitHub Comments
Hey @patrickhulce I tried running chrome using dockers and health checks are passed for chrome installation, but the error says chrome launcher waiting for browser.
+ npx lhci autorun --collect.url=https://nodejs.org/ ✅ .lighthouseci/ directory writable ⚠️ Configuration file not found ✅ Chrome installation found Healthcheck passed! Running Lighthouse 3 time(s) on https://nodejs.org/ Run #1...failed! Error: Lighthouse failed with exit code 1 at ChildProcess.child.on.code (/usr/local/lib/node_modules/@lhci/cli/src/collect/lighthouse-runner.js:103:21) at ChildProcess.emit (events.js:197:13) at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12) Fri, 20 Dec 2019 18:59:15 GMT ChromeLauncher Waiting for browser. Fri, 20 Dec 2019 18:59:15 GMT ChromeLauncher Waiting for browser... Fri, 20 Dec 2019 18:59:15 GMT ChromeLauncher Waiting for browser..... Fri, 20 Dec 2019 18:59:16 GMT ChromeLauncher Waiting for browser....... Fri, 20 Dec 2019 18:59:16 GMT ChromeLauncher Waiting for browser.........
My docker file for installing chrome, lighthouse `RUN apt-get update && apt-get install -y
apt-transport-https
ca-certificates
curl
gnupg
–no-install-recommends
&& curl -sSL https://deb.nodesource.com/setup_12.x | bash -
&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
&& echo “deb https://dl.google.com/linux/chrome/deb/ stable main” > /etc/apt/sources.list.d/google-chrome.list
&& apt-get update && apt-get install -y
google-chrome-stable
fontconfig
fonts-ipafont-gothic
fonts-wqy-zenhei
fonts-thai-tlwg
fonts-kacst
fonts-symbola
fonts-noto
fonts-freefont-ttf
nodejs
–no-install-recommends
&& apt-get purge --auto-remove -y curl gnupg
&& rm -rf /var/lib/apt/lists/* ARG CACHEBUST=1
Installing lighthouse latest version
RUN npm install -g lighthouse
Installing LHCI latest version
RUN npm install -g @lhci/cli`
It’d hard to figure out which options you’re actually trying to use @DinakarC-practise. Also take a look at the Chrome output to see what it’s complaining about.
Now
/tmp/chrome-1/chrome-out.log
and/tmp/chrome-1/chrome-err.log
should contain why Chrome failed to start.