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.

Lambda unable to start Chrome

See original GitHub issue

Hello,

After redeploying examples/serverless-framework/aws from Debian and running a GET request on /screenshot I started seeing this error message on screenshot lambda’s logs:

(DEBUG=*)

@serverless-chrome/lambda: Spawning headless shell
@serverless-chrome/lambda: ChromeLauncher No debugging port found on port 9222, launching a new Chrome.
@serverless-chrome/lambda: Launcher Chrome running with pid 12 on port 9222.
@serverless-chrome/lambda: Waiting for Chrome 0
@serverless-chrome/lambda: Waiting for Chrome 1
@serverless-chrome/lambda: Waiting for Chrome 2
@serverless-chrome/lambda: Waiting for Chrome 3
@serverless-chrome/lambda: Waiting for Chrome 4
@serverless-chrome/lambda: Waiting for Chrome 5
@serverless-chrome/lambda: Waiting for Chrome 6
@serverless-chrome/lambda: Waiting for Chrome 7
@serverless-chrome/lambda: Waiting for Chrome 8
@serverless-chrome/lambda: Waiting for Chrome 9
@serverless-chrome/lambda: Waiting for Chrome 10
@serverless-chrome/lambda: Error trying to spawn chrome: { Error: connect ECONNREFUSED 127.0.0.1:9222 at Object._errnoException (util.js:1022:11) at _exceptionWithHostPort (util.js:1044:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14) code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect',
@serverless-chrome/lambda: stdout log:
@serverless-chrome/lambda: stderr log: [1207/095730.184141:WARNING:resource_bundle.cc(358)] locale_file_path.empty() for locale prctl(PR_SET_NO_NEW_PRIVS) failed Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 84: Having multiple <family> in <alias> isn't supported and may not work as expected Fontconfig warning: "
Error occured in serverless-plugin-chrome wrapper when trying to ensure Chrome for default() handler. { flags: [ '--window-size=1280,1696', '--hide-scrollbars' ], chromePath: '/var/task/headless-chromium' } Error: Unable to start Chrome. If you have the DEBUG env variable set,there will be more in the logs. at /var/task/src/handle
{
    "errorMessage": "Unable to start Chrome. If you have the DEBUG env variable set,there will be more in the logs.",
    "errorType": "Error",
    "stackTrace": [
        "/var/task/src/handlers/screenshot.js:3254:13",
        "Generator.throw (<anonymous>)",
        "step (/var/task/src/handlers/screenshot.js:3189:193)",
        "/var/task/src/handlers/screenshot.js:3189:404",
        "<anonymous>",
        "process._tickDomainCallback (internal/process/next_tick.js:228:7)"
    ]
}

Anyone else seeing this?

I don’t know if it’s the same issue but I have these warnings during deployment :

WARNING in ./node_modules/ws/lib/BufferUtil.js
Module not found: Error: Can't resolve 'bufferutil' in '/home/sls-chrome/node_modules/ws/lib'
 @ ./node_modules/ws/lib/BufferUtil.js 35:21-42
 @ ./node_modules/ws/lib/Sender.js
 @ ./node_modules/ws/index.js
 @ ./node_modules/chrome-remote-interface/lib/chrome.js
 @ ./node_modules/chrome-remote-interface/index.js
 @ ./.build/src/handlers/bjighcv7bla___requestLogger.js
 @ ./.build/src/handlers/requestLogger.js

WARNING in ./node_modules/@serverless-chrome/lambda/dist/bundle.es.js
Module not found: Error: Can't resolve 'chrome-launcher' in '/home/sls-chrome/node_modules/@serverless-chrome/lambda/dist'
 @ ./node_modules/@serverless-chrome/lambda/dist/bundle.es.js 346:52-78
 @ ./.build/src/handlers/version.js

WARNING in ./node_modules/ws/lib/Validation.js
Module not found: Error: Can't resolve 'utf-8-validate' in '/home/sls-chrome/node_modules/ws/lib'
 @ ./node_modules/ws/lib/Validation.js 10:22-47
 @ ./node_modules/ws/lib/Receiver.js
 @ ./node_modules/ws/index.js
 @ ./node_modules/chrome-remote-interface/lib/chrome.js
 @ ./node_modules/chrome-remote-interface/index.js
 @ ./.build/src/handlers/bjighcv7bla___requestLogger.js
 @ ./.build/src/handlers/requestLogger.js

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:6

github_iconTop GitHub Comments

10reactions
abadrajacommented, Dec 12, 2018

Try to comment/remove DEBUG: “*” from serverless.yml Worked for me.

1reaction
deckarddcommented, Dec 13, 2018

@Huljo you are missing the ‘chrome-launcher’ module that is required to run locally.

Module not found: Error: Can't resolve 'chrome-launcher' in '/home/sls-chrome/node_modules/@serverless-chrome/lambda/dist'

Run npm install --save-dev chrome-launcher

@ratsbomb I had the same error when attempting to run locally. The issue I was getting was from Chrome not being passed the --headless flag. This is the error I was seeing:

@serverless-chrome/lambda: Spawning headless shell
@serverless-chrome/lambda: Error trying to spawn chrome: { Error: connect ECONNREFUSED 127.0.0.1:9222
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 9222 }
@serverless-chrome/lambda: stdout log: 
@serverless-chrome/lambda: stderr log: 
(headless-chromium:23447): Gtk-WARNING **: 16:18:07.079: cannot open display: 

Adding the --headless flag to node_modules/@serverless-chrome/lambda/dist/bundle.es.js line 349 fixed it.

        // This let's us use chrome-launcher in local development,
        // but omit it from the lambda function's zip artefact
        try {
          // eslint-disable-next-line
          const { Launcher: LocalChromeLauncher } = require('chrome-launcher');
          chromeInstance = new LocalChromeLauncher({
            chromePath,
            chromeFlags: [...flags, '--headless'],
            port
          });
        } catch (error) {
          throw new Error('@serverless-chrome/lambda: Unable to find "chrome-launcher". ' + "Make sure it's installed if you wish to develop locally.");
        }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Selenium/Chromedriver/Chromium(86) issues AWS Lambda
Basically in a couple of minutes I was able to setup my container image linked to Lambda and it's running: Python 3.9.8; Chromium...
Read more >
Setting up a Selenium web scraper on AWS Lambda with ...
I'm just trying to run my python code to test without Docker even Lambda on just EC2 as got stuck on Makefile. selenium.common.exceptions.WebDriverException: ......
Read more >
chrome-aws-lambda - npm
Chromium Binary for AWS Lambda and Google Cloud Functions. ... Start using chrome-aws-lambda in your project by running `npm i ...
Read more >
Running Headless Chrome with AWS Lambda Layers
Learn how to run Chrome headless in AWS lambda via Puppeteer in a ... sections you will be able to run a much...
Read more >
Fix this error when using Puppeteer on Lambda - YouTube
Failed to launch the browser process - Fix this error when using Puppeteer ... Chrome -aws- lambda currently only works on the x86_64...
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