page.goto freezes on Google Cloud Functions for some websites

我怕爱的太早我们不能终老 提交于 2020-01-15 09:57:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!