puppeteer: TimeoutError: Timed out after 30000 ms while trying to connect to Chrome!
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) } }`
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 23
- Comments: 124
@mathiasbynens I belive this should be reopened, still a lot of people seem to have this error.
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.
Hi everyone! I had a similar error:
TimeoutError: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r818858 is guaranteed to work.
I fixed it by specifying that particular revision number when launching my puppeteer browser. Note that the revision number on the second line was simply copied and pasted from the error message I received.
Read more about browserFetcher here.
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.
And then you need to await the result.
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
AFTER
For those facing a similar issue, note that this error can come from your process being starved by out of memory. For us, we faced this issue because our kubernetes pod did not have enough memory to answer multiple concurrent requests. Increasing your allocated memory could solve your issue. I suspect too little cpu can also affect the performance as well.
@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
Yes, but it’s a different kind of error 😃
I got this error only when running on my Apple Silicon (with
--platform linux/amd64
) but it works perfectly on Intel CPU or cloud providers.I am getting the same error using Cloud functions triggered by pubsub
Error: TimeoutError: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r1036745 is guaranteed to work.
Node 16 puppeteer: “17.1.3”
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 encounter the same issue on MacOS, after switch to
{headless: false}
then switch back to{headless: true}
, it works. I think the computer need us to allow the chromium first with headless false, after that, it can work in headless mode silently.This issue is still happening.
I’m using the latest puppeteer version (2.0.0) and receiving this error.
I also sometimes get this error:
It is strange that I set the value to 120,000 for
setDefaultTimeout
andsetDefaultNavigationTimeout
, but the error message indicates 30,000!More code:
Versions: node v16.14.0 chromium win64-982053 windows 10 headless: true proxy: yes puppeteer-extra-plugin-stealth@2.9.0 puppeteer-page-proxy@1.2.8 puppeteer-proxy@2.1.2 puppeteer@13.7.0
Agreed with @dcts, I am getting the same error with puppeteer 5.2.1
@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 updatedpuppeteer
to v4 and still seeing this from time to time.@tbadlov thank you man, you saved my day, i was struggling here for hours.
That’s exactly my problem. What exactly do you mean by changing it to respond only after Puppeteer is done?
It’s magic. I have used my simpliest script last week - it’s work. Today, no updates, but it’s not working with the same issue. It is a normal?
Node: 18.9.0 Pptr: ^18.0.5
We eventually increased the memory limit of our azure function. The timeouts would occur when the page had javascript redirects. So in those cases puppeteer would actually render two pages.
Getting the same issue; node 16 puppeteer 14.3.0
Same problem here ):
@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 loggedinstalling chromium r782078
I removed the launch options:
--single-process
,it’s work.🤡So what seemed to fix it for me is to simply make sure I’m spawning only one instance of the browser instead of many. In case of both AWS Lambda/Google Cloud Functions the instance managing the function spins up, the first execution is totally fine, but the next execution (in a short timeframe) will fail, because the chrome instance is already up. A simple solution is to create separate function ala
prepareBrowser
and make sure to cache the returnedbrowser
and check inside the main handler whether it’s there already or not. If it’s there then just re-use it. For example:I guess that killing the browser at the end of the function should also solve the problem, but “caching” seems to be more appropriate 🤔 Just make sure you
await browser.close()
, because if you don’t doawait
then the browser won’t close properly before the function ends.Had the same problem. There’s a recent stackoverflow post about running puppeteer on WSL2 and the problem was that my firewall prevented access to my x-server.
I followed the instruction and got it to work!
https://stackoverflow.com/questions/73561240/running-puppeteer-on-wsl2
puppeteer-cluster randomly crashes
@paveltretyakovru did you allocate enough memory?
@saldous , aloha! Thanks for your attention.
My script stoping on “Launch browser”, and I can’t see log with “Opening page”. And after some time I see the issue message.
UPD:
… so… something wrong with WSL, but I repeat - I used my script many taimes in last month 😦
I am having this issue too, on Firebase Functions. Can’t figure it out. Works fine ~20% of the time and fails all others with timeout.
same node 16 puppeteer 14.1
Is it in headless: false mode ?
I had the issue on firebase/gcloud, but only once, so I just re-run the function and worked fine, couldn’t replicate it again…
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.
Yes google-cloud but I also tried using firebase cloud-functions. Error occurs on both.