sambaiz / puppeteer-lambda-starter-kit

Starter Kit for running Headless-Chrome by Puppeteer on AWS Lambda.
MIT License
580 stars 82 forks source link

Example not working when I publish #40

Open pachirulo opened 5 years ago

pachirulo commented 5 years ago

Hi everyone,

I can't make it run the basic sample at index script on a lambda function, here's what I did:

Clone this repo and then run npm install... test locally and works.

Then I run serverless deploy, everything get published, but when I run I always have this issue: "errorMessage": "No node found for selector: #lst-ib", (to test, I simply go to the lambda function, and run a test)

Actually, I can't inspect any element, If I use waitForSelector I have a timeout, so I assume that page never get loaded.

Here's part of log:

START RequestId: 031bea5a-d60d-11e8-94d7-015d775a53cf Version: $LATEST 2018-10-22T15:13:22.647Z 031bea5a-d60d-11e8-94d7-015d775a53cf setup local chrome 2018-10-22T15:13:24.574Z 031bea5a-d60d-11e8-94d7-015d775a53cf setup done 2018-10-22T15:13:25.359Z 031bea5a-d60d-11e8-94d7-015d775a53cf launch done: HeadlessChrome/67.0.3361.0

Is there an issue with this build or I'm missing something?

Thanks in advance.

vbrundic commented 5 years ago

Your browser is starting properly, but must likely puppeteer isn't working. The problem here is that only certain versions of puppeteer will work with this compiled binary included in the package. At the moment, in package.json you have puppeteer dependency declared with version "^1.0.3" which means, when you run npm install it will fetch the latest available package. Anything up till 1.10 works, but if you install 1.11 or 1.12 - it will fail.

Just use the 1.0.3 puppeteer with the 67 binary and you'll be good to go. Also, change the package.json

prithvi514 commented 5 years ago

@vbrundic I deployed the package.zip with chrome

  1. without modifying package.json
  2. changing puppeteer version to ~1.3.0 in package.json and re-packaging

Both resulted in the same error. Please help


START RequestId: c6f56420-aca0-46ee-b8e8-26f9780d85ca Version: $LATEST
END RequestId: c6f56420-aca0-46ee-b8e8-26f9780d85ca
REPORT RequestId: c6f56420-aca0-46ee-b8e8-26f9780d85ca  Duration: 3003.29 ms    Billed Duration: 3000 ms    Memory Size: 128 MB Max Memory Used: 87 MB  
2019-02-06T05:46:54.232Z c6f56420-aca0-46ee-b8e8-26f9780d85ca Task timed out after 3.00 seconds```
anagio commented 5 years ago

I was running into this same issue and it was due to a newer version of puppeteer being installed. I deleted my node_modules folder then pinned the version of puppteer in my package.json to "puppeteer": "1.10" and ran npm install. I re packaged and deployed and the sample script is working for me I see the source logged but also the element just has a bad selector (I think). So it's working if you see the html in cloudwatch logs.

image

jprivillaso commented 5 years ago

It would be nice if anyone states explicitly the versions which are compatible with this lib :) Took me so much time to realize that I was using the wrong version of puppeteer too. It only works for versions till ^1.1.0 by the time I'm writing this comment. Thanks in any case for the great job 👍

alexandrzavalii commented 5 years ago

I had "puppeteer": "1.1.1" and it was silently failing, without any exceptions. 1.1.0 version works!

feliun commented 5 years ago

With this version I can't find a puppeteer version that works, not even 1.1.0 :( It gets stuck in this line

jprivillaso commented 5 years ago

@feliun I am using the other file headless_shell.tar.gz. And I'm using puppeteer 1.1.1 I didn't try with the other one. It's working fine for me. Whenever it gets stuck at the line 'newPage' it is a version problem for sure .

feliun commented 5 years ago

I just downloaded the exact example from the repo, deployed the lambda and didn't work out of the box with 1.1.1. Some people stated the puppeteer version should be downgraded but not even like that. If it's not the code, could it be something different on my lambdas @jprivillaso ? Maybe the region or the stage?

feliun commented 5 years ago

Bloody hell! Yeah I was using the caret coming from the repo. When I changed my package.json to "puppeteer": "~1.1.0", it did work!

jprivillaso commented 5 years ago

I can share later the codebase that I am using if you want

mglasgow commented 5 years ago

I had the same problem. I've submitted two PRs to update this starter kit: First pins puppeteer to v1.3.0, which is the latest which puppeteer itself bundled with chrome v67: https://github.com/sambaiz/puppeteer-lambda-starter-kit/pull/45 Second PR updates to nodejs 8.10 syntax and fixes the google query element selector: https://github.com/sambaiz/puppeteer-lambda-starter-kit/pull/46

Hopefully these PRs will be integrated soon. Otherwise, you can find them already integrated on my fork: https://github.com/mglasgow/puppeteer-lambda-starter-kit