Skip to content
This repository was archived by the owner on Nov 24, 2018. It is now read-only.
This repository was archived by the owner on Nov 24, 2018. It is now read-only.

blank page on lambda environment #414

@selul

Description

@selul

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.

Activity

lhadjchikh

lhadjchikh commented on Mar 11, 2018

@lhadjchikh

+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
tvpavan

tvpavan commented on Mar 12, 2018

@tvpavan

Exact same issue blank jpg
Chromeless 1.5.1
Serverless 1.26.1

wongfei2009

wongfei2009 commented on Mar 12, 2018

@wongfei2009

+3 ( if not +1 ) Exact same issues for blank jpg or Error: wait("input[name="q"]") timed out after 10000m

andreaskweber

andreaskweber commented on Mar 15, 2018

@andreaskweber

+4 same here

ddura

ddura commented on Mar 15, 2018

@ddura

+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.

shawnliujw

shawnliujw commented on Mar 19, 2018

@shawnliujw

+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

cantsin

cantsin commented on Mar 20, 2018

@cantsin

Throwing in another +1, just got this.

chromeless 1.5.1
serverless 1.26.1

danrubins

danrubins commented on Mar 21, 2018

@danrubins
Contributor

FWIW, pinning the serverless-plugin-chrome version to 1.0.0-38, as mentioned in #387 resolved this for me.

shawnliujw

shawnliujw commented on Mar 22, 2018

@shawnliujw

@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

martco

martco commented on Mar 23, 2018

@martco

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.

dmeola

dmeola commented on Mar 24, 2018

@dmeola

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.

adrach

adrach commented on Apr 10, 2018

@adrach

+1 the same issue on 1.0.0-41
deleting node_modules, pinning to -38 and re-deploying fixed the issue

co851002

co851002 commented on May 2, 2018

@co851002

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

mitin001

mitin001 commented on May 2, 2018

@mitin001

@co851002 In your package.json, try reinstalling node_modules after setting "chromeless":"1.2.0" instead of "chromeless":"^1.3.0".

mitin001

mitin001 commented on May 2, 2018

@mitin001

@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.

mitin001

mitin001 commented on May 9, 2018

@mitin001

@co851002 Hey I also noticed that you're not pinning the version of serverless-plugin-chrome to 1.0.0-38. In your package.json you have "serverless-plugin-chrome":"^1.0.0-38" but it should be "serverless-plugin-chrome":"1.0.0-38"

dragg

dragg commented on May 15, 2018

@dragg

@mitin001 Thank you! For me, it working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ddura@martco@tvpavan@shawnliujw@andreaskweber

        Issue actions

          blank page on lambda environment · Issue #414 · schickling/chromeless