I've run through a lot of debugging, and read articles, and cannot figure out why I am getting a
at Promise.then (/workspace/node_modules/puppeteer/lib/cjs/puppeteer/common/LifecycleWatcher.js:106:111) name: 'TimeoutError' }
For the "goto" line below, I've tried adjusting arguments, and tried going back in puppeteer versions in the package.json from version 5 to 4 to 3. The code runs fine locally, but in the Google Cloud Function keeps timing out. I verified that my VPC connector is working by writing a simple fetch function for google.com, so this is purely a Puppeteer in GCF issue.
FYI this is triggered on a PubSub topic.
const puppeteer = require('puppeteer')
const PUPPETEER_OPTIONS = {
  headless: true,
  args: [
    '--disable-gpu',
    '--disable-dev-shm-usage',
    '--disable-setuid-sandbox',
    '--no-first-run',
    '--no-sandbox',
    '--no-zygote',
    '--single-process',
    "--proxy-server='direct://'",
    '--proxy-bypass-list=*',
  ],
};
const closeConnection = async (page, browser) => {
  page && (await page.close());
  browser && (await browser.close());
};
exports.runScraper = async (message, context) => {
    const url = Buffer.from(message.data, 'base64').toString()
    console.log( `triggered with ${url}`)
    
    const browser = await puppeteer.launch(PUPPETEER_OPTIONS);
    const page = await browser.newPage();
    try // open url and get price and title
    {
        console.log( "awaiting goto")
        await page.goto(url, { waitUntil: 'networkidle2' })
        console.log( "awaiting evaluate")
        let item = await page.evaluate( async () => {
            let priceArray = document.querySelector('div.cAIbCF').innerText.split('.')
            return {
                title: document.querySelector('h1 > span').innerText,
                whole: priceArray[0],
                part: priceArray[1]
            }
        }) 
    } // try
    catch (error) {
        console.log( error );
        throw error;
    } finally {
        console.log( "finally closeConnection" );
        await closeConnection(page, browser);
        return;
    }
}
 
    