问题
I am using:
Puppeteer version: 1.13.0
Platform / OS version: Google Cloud
Node.js version: 8
await.page.goto("https://somewebsite.com")
freezes when I deploy it on Google Cloud functions.
I receive timeout error.
Navigation Timeout Exceeded
const browser = await puppeteer.launch({
headless: true,
ignoreHTTPSErrors: true,
args: [
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-setuid-sandbox',
'--no-first-run',
'--no-sandbox',
'--no-zygote',
'--single-process', // <- this one doesn't works in Windows
]
});
const page = await browser.newPage();
try {
await page.goto('https://somewebsite.com',
{ waitUntil: 'networkidle2' });
} catch (error) {
console.log('page.goto ERROR: ', error);
}
I can see it working in different environments:
- AWS
- Locally
It works for all except Google Cloud Functions. However, if I try google.com
it works.
The problem is that the error is not helpful at all, the page.goto
is just timing out.
I was wondering if there is a proper way to debug this?
Could it be OS issue? but then again, AWS and Google cloud are both Linux based?
回答1:
Apparently there is an issue with timing in Puppeteer version 1.13.0. Try downgrading to 1.11.0 and it should work fine.
A similar question was answered in this Stackoverflow question. It points to this discussion.
来源:https://stackoverflow.com/questions/55318724/page-goto-freezes-on-google-cloud-functions-for-some-websites