blank page on lambda environment
selul opened this issue ยท 18 comments
Hello,
I'm trying to run the chromeless via AWS Lambda and i'm getting an odd error which i'm having trouble solving it.
It seems that the screenshots are uploaded to S3 as white pages, i.e -> https://185387363267-us-east-1-chromeless.s3.amazonaws.com/cjelwu0zn000l01qamfomc5ky.png
The script i'm running is:
const {Chromeless} = require('chromeless')
async function run() {
const chromeless = new Chromeless({
remote: {
endpointUrl: 'https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev',
apiKey: 'xxxxxxxxxx',
},
debug: true
})
const screenshot = await chromeless
.goto('https://www.google.com')
.screenshot()
console.log(screenshot)
await chromeless.end()
}
run().catch(console.error.bind(console))
I've tried also this one:
const {Chromeless} = require('chromeless')
async function run() {
const chromeless = new Chromeless({
remote: {
endpointUrl: 'https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev',
apiKey: 'xxxxxxxxxx',
},
debug: true
})
const screenshot = await chromeless
.goto('https://www.google.com')
.type('chromeless', 'input[name="q"]')
.press(13)
.wait('#resultStats')
.screenshot()
console.log(screenshot) // prints local file path or S3 url
await chromeless.end()
}
run().catch(console.error.bind(console))
And i'm getting this error Error: wait("input[name="q"]") timed out after 10000ms
followed by Chromeless Proxy disconnected due to inactivity (no commands sent for 30 seconds).
For both examples, the most relevant CloudWatch log that could be tied to both examples is:
Chrome result undefined
triggered here
I've tried changing the user agent, tested on personal websites with no firewall that could block access and i'm still getting the same error.
Any clue what it could be ?
- Chromeless Version I'm using: 1.5.0
- Serverless Version I'm using: 1.26.1
- Operating System: MacOS Sierra
Thanks a lot for any help.
+1
I'm also getting blank screenshots in S3 and the log message Chrome result undefined
in CloudWatch. I've tried setting the user agent as described in #195, but it didn't help.
Using:
- Chromeless 1.5.1
- Serverless 1.26.1
- Node 9.8.0
- MacOS El Capitan
Exact same issue blank jpg
Chromeless 1.5.1
Serverless 1.26.1
+3 ( if not +1 ) Exact same issues for blank jpg or Error: wait("input[name="q"]") timed out after 10000m
+4 same here
+1 seeing the same issue.
Chromeless 1.5.1
Serverless 1.26.1
Also seeing the same log message. It appears to happen after the .goto call. The queue seems to be returning a null result, which means that the call technically is 'succeeding', so the next call (such as screenshot) continues to execute even though the url hasn't loaded.
+1
chromeless 1.3.0
serverless 1.26.1
node 6.10.3
Error Message:
Running remotely: {"type":"setUserAgent","useragent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"}
Running remotely: {"type":"goto","url":"https://github.com/adieuadieu/serverless-chrome/issues/120"}
Running remotely: {"type":"wait","selector":"#partial-discussion-header > div.gh-header-show > h1 > span.js-issue-title"}
Error: wait("#partial-discussion-header > div.gh-header-show > h1 > span.js-issue-title") timed out after 10000ms
same code runs correctly if i used local chrome
Throwing in another +1, just got this.
chromeless 1.5.1
serverless 1.26.1
FWIW, pinning the serverless-plugin-chrome version to 1.0.0-38, as mentioned in #387 resolved this for me.
@dhrubins cool, it resolve my problems thanks.
here is the package.json i used
{ "name": "chromeless-remotechrome-servie", "version": "1.3.0", "description": "The Chromeless Proxy AWS Lambda service", "homepage": "https://github.com/graphcool/chromeless", "license": "MIT", "engines": { "node": ">= 6.10.0" }, "scripts": { "deploy": "serverless deploy" }, "dependencies": { "aws4": "^1.6.0", "chromeless": "^1.3.0", "cuid": "^1.3.8", "mqtt": "^2.11.0", "source-map-support": "^0.4.15" }, "devDependencies": { "@types/cuid": "^1.3.0", "@types/node": "^8.0.15", "serverless": "^1.19.0", "serverless-offline": "^3.15.3", "serverless-plugin-chrome": "1.0.0-38", "serverless-plugin-typescript": "^1.0.0" } }
NOTE: must use node 6.10 , i used v6.10.3 , and i tried 8.9.0 , failed
Don't forget to run npm run deploy
after pinning serverless-plugin-chrome
version to 1.0.0-38
, like I did for a few hours.
After pinning to 1.0.0-38 I had to run
npm install
to update the dependency in the package.json (shawnLiujianwei has an example above)
then run
npm run deploy
as martco mentioned in order to update the lambda.
+1 the same issue on 1.0.0-41
deleting node_modules, pinning to -38
and re-deploying fixed the issue
After following the above, pinning to 1.0.0-38 as @dhrubins suggested and having the exact same package.json as @shawnLiujianwei, I'm still getting a blank screenshot at ~400bytes. OS is OSX if that makes any difference.
{"name":"chromeless-remotechrome-service","version":"1.3.0","description":"The Chromeless Proxy AWS Lambda service","homepage":"https://github.com/graphcool/chromeless","license":"MIT","engines":{"node":">= 6.10.0"},"scripts":{"deploy":"serverless deploy"},"dependencies":{"aws4":"^1.6.0","chromeless":"^1.3.0","cuid":"^1.3.8","mqtt":"^2.11.0","source-map-support":"^0.4.15"},"devDependencies":{"@types/cuid":"^1.3.0","@types/node":"^8.0.15","serverless":"^1.19.0","serverless-offline":"^3.15.3","serverless-plugin-chrome":"^1.0.0-38","serverless-plugin-typescript":"^1.0.0"}}
Testing code is:
const Chromeless = require('chromeless').default
async function run() {
const chromeless = new Chromeless({
remote: {
endpointUrl: 'https://XXXXXXXXXX.execute-api.eu-west-1.amazonaws.com/dev',
apiKey: 'your-api-key-here',
},
debug: true
})
const screenshot = await chromeless
.goto('https://www.instagram.com/serverlessinc/')
.wait(5000)
.scrollTo(0, 1200)
.screenshot()
console.log(screenshot) // prints local file path or S3 url
await chromeless.end()
}
run().catch(console.error.bind(console))
Console:
Connected to message broker. Running remotely: {"type":"goto","url":"https://www.instagram.com/serverlessinc/"} Running remotely: {"type":"wait","timeout":5000} Running remotely: {"type":"scrollTo","x":0,"y":1200} Running remotely: {"type":"returnScreenshot"} https://XXXXXXXXX-eu-west-1-chromeless.s3.amazonaws.com/cjgp4qyve000301p086qtqiyq.png
@co851002 In your package.json, try reinstalling node_modules after setting "chromeless":"1.2.0"
instead of "chromeless":"^1.3.0"
.
@mitin001 - Nope , still just a blank - https://827074804090-eu-west-1-chromeless.s3.amazonaws.com/cjgpbu6r8000001qrbw0knv1a.png
@co851002 I installed and deployed using npm I installed using this package: https://nodejs.org/download/release/v6.11.2/node-v6.11.2.pkg
I also used this yarn.lock: https://raw.githubusercontent.com/nsfmc/chromeless/6f0e5b4f601f96eedff42b9cfe48ff37619cd3b1/serverless/yarn.lock
Did not need to delete the CloudFormation stack, redeployment worked.
Also, are you taking the screenshot immediately after using the goto command? If so, try chaining .wait(1000) to it before chaining .screenshot() so Chrome gives the page 1 second to load before capturing its screenshot.