page.goto冻结某些网站的Google Cloud Functions [英] page.goto freezes on Google Cloud Functions for some websites
问题描述
我正在使用:
Puppeteer version: 1.13.0
Platform / OS version: Google Cloud
Node.js version: 8
await.page.goto( https://somewebsite.com)
在将其部署到Google Cloud函数上时会冻结。
await.page.goto("https://somewebsite.com")
freezes when I deploy it on Google Cloud functions.
我收到超时错误。
导航超时已超过
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
- 本地
它适用于除 Google云功能以外的所有功能。但是,如果我尝试 google.com
,它会起作用。
It works for all except Google Cloud Functions. However, if I try google.com
it works.
问题是该错误根本没有帮助, page.goto
才超时。
The problem is that the error is not helpful at all, the page.goto
is just timing out.
我想知道是否有适当的方法进行调试?
可能是操作系统问题吗?
,但同样,AWS和Google云都是
Could it be OS issue? but then again, AWS and Google cloud are both Linux based?
推荐答案
显然,Puppeteer 1.13.0版中的计时存在问题。尝试降级到1.11.0,它应该可以正常工作。
Apparently there is an issue with timing in Puppeteer version 1.13.0. Try downgrading to 1.11.0 and it should work fine.
在此Stackoverflow问题。它指向此讨论。
这篇关于page.goto冻结某些网站的Google Cloud Functions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!