question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot Invoke Chrome browser inside Jenkins.

See original GitHub issue

Running 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:closed
  • Created 4 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
DinakarC-practisecommented, Dec 24, 2019

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`

1reaction
patrickhulcecommented, Dec 14, 2019

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.

chromeLauncher.launch({
  chromePath: binPath,
  chromeFlags: ['--headless', '--disable-gpu', '--no-sandbox'],
  userDataDir: '/tmp/chrome-1',
})

Now /tmp/chrome-1/chrome-out.log and /tmp/chrome-1/chrome-err.log should contain why Chrome failed to start.

Read more comments on GitHub >

github_iconTop Results From Across the Web

unable to open chrome browser in jenkins for selenium script
Correct me if I'm wrong, but your Jenkins is running the slaves from a Windows Service and try to open the Chrome browser....
Read more >
not able to run chrome from jenkins server for slenium testing
I am able to execute selenium test cases with headless chrome browser on Linux using jenkins but facing issue without headless. Getting ...
Read more >
Chrome opens, but nothing happens (Selenium) - Jenkins Jira
I have figured out, that Chrome browser opens, because in task-manager I see chrome-browser instances. And when I kill them, ...
Read more >
Can't open Chrome through ssh or with Jenkins - Katalon Studio
However, when I try running the exact same command through a Jenkins (running on the same machine) build shell or after ssh-ing in...
Read more >
Chrome not reachable error when running selenium test via ...
Initially, I suspected the error is because of the below issues: 1. Chrome browser and driver version conflicts in Ubuntu. Removed the existing ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found