Puppeteer: TimeoutError: Timed out after 30000 ms while trying to connect to Chrome!

Created on 2 Aug 2019  Â·  57Comments  Â·  Source: puppeteer/puppeteer

Hello

I try to implement/deploy puppeteer on Google Cloud but I have some issues. What I don't understand, it worked well 2 days ago.
Since then, I have this error:

TimeoutError: Timed out after 30000 ms while trying to connect to Chrome! The only Chrome revision guaranteed to work is r674921 at Timeout.onTimeout

I ran this command and everything seems fine : DEBUG=* node app.js

Version puppeteer : ^1.19.0
Version Node : v8.11.3

And here the code:

`async function main_screenshot(project_id) {
try {
const browser = await puppeteer.launch({
headless: true,
args: ["--window-size=1440,1000", "--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu"]
});
// const browser = await puppeteer.launch({dumpio: true});
const page = await browser.newPage()
page.setUserAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36')
page.setViewport({ width: 1440, height: 721 })
console.log('entering in screenshot zone')
page.setDefaultNavigationTimeout(30000)
await page.goto('https://app.slack.com/client/TLW4JE7AA/CLTFQT9GC')
await page.waitFor(3000)
await page.type('#email', process.env.SLACK_EMAIL)
await page.type('#password', process.env.SLACK_PWD)
await page.waitFor(3000)
await page.click('#signin_btn')
console.log('credentials done')
await page.waitFor(3000)
console.log('so?')
await page.goto('https://app.slack.com/client/TLW4JE7AA/CLTFQT9GC')
await page.waitFor(3000)
console.log('connected to the right environment')
const div = await page.$$('.c-message.c-message--light')
var nuwwmber_loop= 0
for (var i = div.length ; i > 0; i--) {
var text = await (await div[i - 1].getProperty('textContent')).jsonValue();

  if(text.includes(project_id)) {
    number_loop = i
    break
  }
}
// const text = await (await div.getProperty('textContent')).jsonValue();


 const shotResult = await div[number_loop-1].screenshot();
console.log(shotResult)
cloudinaryOptions = {
  public_id: `${project_id}`
}

const results = await uploadToCloudinary(shotResult, cloudinaryOptions)
console.log(results)
browser.close()
return results

} catch (e) {
console.log(e)
}
}`

Most helpful comment

@mathiasbynens I belive this should be reopened, still a lot of people seem to have this error.

All 57 comments

Quick update I downloaded the previous code, no really big changes...

Did you get it to work? Same problem here ):

not yet :/

Same here. Cannot get it to work

I also have this issue,

Node v10.15.3
Puppeteer v1.19.0

I use "puppeteer-core": "^1.19.0",

when I use headless: false, it can work.
But when I use headless:true, it will be TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded

Yes, but it's a different kind of error :)

bumping because I also get this error and can't seem to find a solution. I get both TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded and TimeoutError while connecting to Chrome :(

I'm getting the similar error:

(node:11400) UnhandledPromiseRejectionWarning: TimeoutError: Timed out after 40000 ms whil e trying to connect to Chrome! The only Chrome revision guaranteed to work is r686378 at Timeout.onTimeout (H:\node_modules\puppeteer\lib\Launcher.js:359:14) at ontimeout (timers.js:436:11) at tryOnTimeout (timers.js:300:5) at listOnTimeout (timers.js:263:5) at Timer.processTimers (timers.js:223:10) (node:11400) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error ori ginated either by throwing inside of an async function without a catch block, or by reject ing a promise which was not handled with .catch(). (rejection id: 1) (node:11400) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process wi th a non-zero exit code.

I've tried numerous 'fixes' and nothing seems to work.

Node v10.16.3
Puppeteer v1.20 (edit)

Having the same problem was anybody able to fix this?

If it helps anyone my issue with was due to the usage of Puppeteer in Google Cloud Function and have it running in the background. I changed the function to respond only after Puppeteer is done and it worked just fine.

If it helps anyone my issue with was due to the usage of Puppeteer in Google Cloud Function and have it running in the background. I changed the function to respond only after Puppeteer is done and it worked just fine.

That's exactly my problem. What exactly do you mean by changing it to respond only after Puppeteer is done?

@bruriah1999 your entry function will have a response call. Once invoked the functions technically terminated which means all other tasks are considered background tasks and won’t execute.

Check the Function Execution Timeline in this article https://cloud.google.com/functions/docs/concepts/exec

@tbadlov thank you man, you saved my day, i was struggling here for hours.

I also faced the same problem. it got fixed on upgrading to the latest package version.
"puppeteer": "^2.0.0",

I'm using the latest puppeteer version (2.0.0) and receiving this error.

Unfortunately i'm having this issue with 2.1.1
Maybe something that could help is that i'm running it like
ip netns exec bet365 node foobar
Without using the namespace it's working as expected...

I had the same problem.

I noticed that if you deploy it using the PUB/SUB trigger, this would happen. If you use HTTP as trigger instead, it runs just fine.

node.js 10 (beta)
"puppeteer": "^2.1.1",
"puppeteer-extra": "^3.1.9",

I'm having this issue with "puppeteer": "^3.0.1" happens randomly after several hundreds of browsers have been launched and closed previously.
I'm using GCE instances.

Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r737027 is guaranteed to work

I'm also using these extensions
"puppeteer-extra": "^3.1.9", "puppeteer-extra-plugin-adblocker": "^2.11.3", "puppeteer-extra-plugin-anonymize-ua": "^2.2.8", "puppeteer-extra-plugin-block-resources": "^2.2.4", "puppeteer-extra-plugin-stealth": "^2.4.9"

I am also having this issue
using puppeteer 3.1.0

Uncaught (in promise) TimeoutError: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r756035 is guaranteed to work.

@mathiasbynens #6011 meant to fix **** Exception caught: TimeoutError: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r756035 is guaranteed to work.. ? I updated puppeteer to v4 and still seeing this from time to time.

Seeing this error
"puppeteer": "^3.0.2"

i'm obtaining this error randomly after upgrading to puppeteer 3.1
using puppeteer 2 on the same test i never got this error.

moving to puppeteer 5 even i'm not able to understand if this fix https://github.com/puppeteer/puppeteer/pull/6011 is inside puppeteer 5

testing puppeteer 5.2.1, puppeteer 5 doesn't solve the issue.

I'm getting this too;
TimeoutError: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r782078 is guaranteed to work which is weird cause we have 782078 installed???

having the same issue. Using puppeteer 4.0.1.

same! @dcts

@westonwatson @dcts @CalebDelbridge which version of puppeteer are you using?

My setup is

functions.runWith({ memory: "1GB" }).firestore.document(...).onCreate(...)

Still working on this so if anyone has same issue or suggestions I am very open :)

@dcts try upgrading to puppeteer 5.2.1

@andreabisello just upgraded but still I get the same error. Which is really weird, i have now puppeteer 5.2.1 running, and during install it even logged installing chromium r782078
Bildschirmfoto von 2020-08-01 17-28-18

Agreed with @dcts, I am getting the same error with puppeteer 5.2.1

I'm facing the same error for any puppeteer version > 2.0.0
I upgraded recently to 5.2.1 to see if the error is fixed, but the problem persists.
I'm surprised there are not more people facing the same problem.

@shubhams You summoned me my Lord? :)
I'm getting this issue atm here's my details. I'm going to try with previous versions

Node V10.x
"chrome-aws-lambda": "^5.1.0",
"puppeteer-core": "^5.1.0"

I do see chrome responding to Browser.getVersion

2020-08-08T22:12:22.434Z puppeteer:protocol:RECV â—€ 
{
    "id": 17,
    "result": {
        "protocolVersion": "1.3",
        "product": "HeadlessChrome/84.0.4147.0",
        "revision": "@926b5cca60c2451e9d55b4556fc2c328030736d7",
        "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/84.0.4147.0 Safari/537.36",
        "jsVersion": "8.4.379"
    }
}

@shubhams i think there is something that spawn the problem in our test cases. for example, i get the problem only in continous integration Atlassian Bamboo windows 10 server, even it simply call the same command of the same project i will call in my windows 10 machine, and i never found the problem calling the same command from my pc.

i confirm problem started upgrading from version 2.0.0,

but in my case, maybe it only luck for now, 5.2.1 solved the issue. i never go the issue in the latest 7 days of test.

are you able to crete a repository that reproduce the issue in a minimal configuration?

@andersonaguiar I could try to setup a repo to recreate the bug, but Im not sure how i would do that, since it only occurs on google cloud. On my local machine it works without error. Would it be usefull to provide the whole google cloud function code without credentials to google cloud? (then the person looking into it would need a google account themself and create a cloud function, enable billing etc...).

@dcts, Can you reproduce the issue in a docker container? I am getting the same error in my docker.

Getting the same issue, puppeteer 3.3.0 with codeceptjs

This needs to be opened, getting same issue with puppeteer latest running from CI server, only headless: true works.

instead in my use case puppeteer 5.2.1 seems to have solved the issue.
i'm using atlassian bamboo as continous integration,
i have 4 task running every day but from about one months i never got the timeout issue.
maybe there is something different we are missing

Finally I solved it (at least for my condition).

I'm using Cloud Functions as a Background Function (Triggers when a Firestore Document is created. Though should work for PUB/SUB I imagine).

I needed to make my exported function asynchronous.

Capture

And then you need to await the result.

Capture2

Otherwise, if you look at the Cloud Function logs, you'll see that your function starts and finishes very quickly (like 200ms). After I made my function asynchronous, it took around 13000ms and stopped giving errors.

Here's my logs:

BEFORE
log01

AFTER
log02

Bump, tried 5.2.1, 2.1.0. Both get the same timeout error.

Hello

I have this issue on and off. It seems that if you initialise the browser object wrong (because your code is wrong) you can get this error
Also, if your lambda does not have internet access

For me 5.2.1 works, with the right code
Also, I use https://github.com/Seikho/node-http-ping to confirm that I can connect to sites over http or https

Sorry I don't have anymore advice

@WinstonN Thanks for your reply and the tips. But I don't get what you mean with

It seems that if you initialise the browser object wrong (because your code is wrong) you can get this error

Can you provide an example of code that correctly initialized the browser object? I have my example fully working on my local environment and also on https://try-puppeteer.appspot.com/.

Heres example code (running a search on amazon):

const puppeteer = require('puppeteer'); // not needed on https://try-puppeteer.appspot.com/
const browser = await puppeteer.launch({args: [ '--no-sandbox']});
const context = await browser.createIncognitoBrowserContext();
const page = await context.newPage();
const searchQuery = "laptop";
const url = `https://www.amazon.com/s?k=${searchQuery}`;

await page.goto(url);
console.log(await page.content());
await page.screenshot({path: 'screenshot.png'});
await context.close();
await browser.close();

@mathiasbynens I belive this should be reopened, still a lot of people seem to have this error.

@dcts is that your entire code? You can't use "await" outside of an asynchronous function

@dcts is that your entire code? You can't use "await" outside of an asynchronous function

No that is code that you can insert to try-puppeteer. But to run it locally you can simply use a node in experimental mode where await is enabled

node --experimental-repl-await

I saw your post above but for me the error has nothing to do with async syntax.

Gotcha. Where are you deploying? Is this for Google Cloud?

Yes google-cloud but I also tried using firebase cloud-functions. Error occurs on both.

It took me forever to get it working on Google Cloud. Can you post your code that you're deploying to Google Cloud?

I am also experiencing this issue in puppeteer 2.1.1 used with AWS batch jobs. What's strange is the code base in our dev and prod environments is identical and had been running for a while. This week, it quit working in prod, but still runs in dev.

I got this same error (Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r818858 is guaranteed to work.) when trying to deploy Puppeteer 5.5.0 to Google Cloud Functions.

I found that it was hanging at await browser.newPage();

This is similar to this issue

Upgrading to Node 12 made no difference. I got it running by downgrading to Puppeteer 2.1.1, and increasing the function memory to 512 MB.

I increased the function memory because I got an out of memory error with 2.1.1. I did check if there was some kind of silent memory issue with 5.5.0, but no, even with 4GB this didn’t run.

Same error. Puppeteer 5.5.0 running Google Cloud. Our applications is running about 1 year and now in our dev environments works but stopped working in prod in this week. Somebody can help?

Has this problem been solved?How to solve this problem?

I'm experiencing same thing using lighthouse-puppeteer on an Unbuntu 20 VM on GCP.

Workaround I found, is running killall chrome and giving it 5 seconds before retrying.

I know that's unlikely to help many of you, cause my use-case is weird. 🤞

How do you handle it?

@bruriah1999 your entry function will have a response call. Once invoked the functions technically terminated which means all other tasks are considered background tasks and won’t execute.

Check the Function Execution Timeline in this article https://cloud.google.com/functions/docs/concepts/exec

How did you solve it?What is the version of puppeter used?I had this problem with CentOS

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rlog picture rlog  Â·  78Comments

aherriot picture aherriot  Â·  172Comments

fortes picture fortes  Â·  191Comments

optikalefx picture optikalefx  Â·  49Comments

KJ1i picture KJ1i  Â·  46Comments