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
````
I got same errors, too.
I tried this.
export NPM_CONFIG_CHROMIUM_CHANNEL=dev
npm install @serverless-chrome/[email protected]
but. another errors comes. :cry:
Error capturing screenshot for https://www.google.com { 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 }
2018-12-07T12:15:06.612Z bbc18b4d-fa19-11e8-bf2d-37a6631a6dda
{
"errorMessage": "connect ECONNREFUSED 127.0.0.1:9222",
"errorType": "Error",
"stackTrace": [
"Object._errnoException (util.js:1022:11)",
"_exceptionWithHostPort (util.js:1044:20)",
"TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)"
]
}
but. i guess, chrome is launched anyway? hm...
Hi @ratsbomb
I gave a try to your solution but nothing changed.
Do you have any error during your deployment ?
@Huljo No, I don't have any errors on deploying. but i tried to capture screenshot, i got errors upper. i don't know what is going on...
Try to comment/remove DEBUG: "*" from serverless.yml
Worked for me.
@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.");
}
Try to comment/remove DEBUG: "*" from serverless.yml
Worked for me.
Thanks @abadraja, seems to work for me too.
@deckardd I added chrome-launcher but still have the warning.
Most helpful comment
Try to comment/remove DEBUG: "*" from serverless.yml
Worked for me.