adieuadieu/serverless-chrome

Is it still working?

anvaka opened this issue ยท 15 comments

Hello,

First of all, thank you for making this software!

I tried using your compiled binaries. The browser starts properly in AWS lambda, but no inspectable targets are available and AWS lambda (those are required to find websocket URL, at /json/protocol endpoint). The AWS lambda just times out. There are no specific stdout or stderr entries which would indicate a problem.

When I launch headless shell in the lambda-like linux environment - it starts properly, and I can inspect pages.

Just wanted to see if it's broken only for me, or other people experience similar problem?

Here is full request log from the screenshot example from this repository

START RequestId: 8b581a1c-eae0-11e7-bf6f-49d3bc99541a Version: $LATEST
2017-12-27T08:32:58.972Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Spawning headless shell
2017-12-27T08:32:58.973Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda ChromeLauncher No debugging port found on port 9222, launching a new Chrome.
2017-12-27T08:32:58.973Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Chrome already running with pid 12.
2017-12-27T08:32:58.973Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 0
2017-12-27T08:32:59.475Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 1
2017-12-27T08:32:59.976Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 2
2017-12-27T08:33:00.477Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 3
2017-12-27T08:33:00.979Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 4
2017-12-27T08:33:01.480Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 5
2017-12-27T08:33:01.982Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 6
2017-12-27T08:33:02.484Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 7
2017-12-27T08:33:02.985Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 8
2017-12-27T08:33:03.486Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 9
2017-12-27T08:33:03.988Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Waiting for Chrome 10
2017-12-27T08:33:03.988Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda Error trying to spawn chrome: { Error: connect ECONNREFUSED 127.0.0.1:9222
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 9222 }
2017-12-27T08:33:03.989Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda stdout log: 
2017-12-27T08:33:03.989Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	@serverless-chrome/lambda stderr log: [1227/082829.785866:WARNING:resource_bundle.cc(366)] locale_file_path.empty() for locale 
prctl(PR_SET_NO_NEW_PRIVS) failed

DevTools listening on ws://127.0.0.1:9222/devtools/browser/cac79c47-1495-45e0-a956-e6bd139b80a7
[1227/082829.933962:VERBOSE1:webrtc_internals.cc(109)] Could not get the download directory.
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: "/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: "/etc/fonts/conf.d/30-metric-aliases.conf", line 93: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 93: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 102: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 102: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 33: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 59: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 68: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 68: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 79: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 79: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 79: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 88: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 23: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 39: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 56: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 66: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 66: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 66: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 75: Having multiple <family> in <alias> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 75: Having multiple <family> in <alias> isn't supported and may not work as expected
[1227/082913.870970:WARNING:sandbox_ipc_linux.cc(121)] poll: Operation not permitted (1)
[1227/082914.095962:WARNING:histograms.cc(40)] Started multiple compositor clients (Browser, Renderer) in one process. Some metrics will be disabled.
[1227/082914.096637:INFO:child_thread_impl.cc(840)] ChildThreadImpl::EnsureConnected()

2017-12-27T08:33:03.989Z	8b581a1c-eae0-11e7-bf6f-49d3bc99541a	Error occured in serverless-plugin-chrome wrapper when trying to ensure Chrome for default() handler. { flags: [ '--window-size=1280x1696', '--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/handlers/screenshot.js:3354:13
at throw (native)
at step (/var/task/src/handlers/screenshot.js:3295:191)
at /var/task/src/handlers/screenshot.js:3295:402
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
END RequestId: 8b581a1c-eae0-11e7-bf6f-49d3bc99541a

This looks suspicious:

[1227/082913.870970:WARNING:sandbox_ipc_linux.cc(121)] poll: Operation not permitted (1)

Hi @anvaka โ€” Try using a different release channel of Chromium. Perhaps try the dev channel by setting an environment variable export NPM_CONFIG_CHROMIUM_CHANNEL=dev in your shell, and then re-installing the @serverless-chrome/lambda npm package (watch the npm output, it'll confirm that it installed the dev-channel binaries.)

The stable channel of Chromium recently jumped to 63 and it's possible something broke between 62 and 63 which wasn't correctly caught/reported by the integration tests ๐Ÿ˜ญ

Thank you @adieuadieu

Using dev channel works

Hi @anvaka โ€” I can't seem to reproduce this issue with the stable channel builds. Which region are you deploying to?

It used us-east-1 if I remember correctly

Hey @adieuadieu,
I encountered this problem today. In my case it happened after I closed Chrome with Browse.close CDP call, I looked into code and I believe the problem is in spawn method of Launcher. When Chrome is closed without using @serverless-chrome/lambda on the next call flow is as follows:

  1. In index.js: Launcher.launch() is called on existing chromeInstance object
  2. In Launcher.launch: isReady is called and rejects because chrome is not running
  3. In Launcher.launch: spwan is called
  4. In Launcher.spawn: spawnPromise is checking if (this.chrome) { and because it exists it resolves with pid of previously spawned chrome.
  5. In Launcher.spawn: waitUntilReady is waiting for Chrome and rejects.

Just tried latest and dev version - getting a blank page by default.

Looking into the logs of the latest dev/stable releases - I don't see chrome fetches javascript assets.
I downloaded https://github.com/adieuadieu/serverless-chrome/releases/tag/v1.0.0-31 and now see that js requests are made. However the screenshot is still blank. Not sure what's causing it. Going to try pulling older version of the surrounding library (I replaced only binary file)

@anvaka Did you figure it out?

I seem to be getting a blank page when I try to take a screenshot too. Also, if I try to print document outerHtml it is blank: <html><head></head><body></body></html>

I am still having issues unless I set the normal release. If I use @adieuadieu 's instructions to set NPM_CONFIG_CHROMIUM_CHANNEL=dev the project executes locally, however, it still fails when I run on lambda.

Locally I am running on Windows 10, running on SAM Local.

Error Message:
TypeError: Cannot read property 'toString' of undefined
at /var/task/node_modules/@serverless-chrome/lambda/dist/bundle.cjs.js:206:54

I had the same issue.
I was using serverless-chrome/lambda: 1.0.0-43
Changing it to serverless-chrome/lambda: 1.0.0-38 fixed this issue.
This thread helped me solve the issue.

Hope it helps

I have created a little demo of how things work using the AWS SAM framework. This was created using the latest version of the frameworks.

https://github.com/justengland/serverless-chrome-lambda

Any progress on a PR for this issue? I ran into this problem too and using the workaround @zigzhang suggested is working.

Does anyone know what poll: Operation not permitted means? I get it daily when my laptop returns from sleep/suspend.