Puppeteer: TimeoutError: Timeout exceeded while waiting for event at Timeout.setTimeout (/home/site/wwwroot/node_modules/puppeteer/lib/helper.js)

Solution for Puppeteer: TimeoutError: Timeout exceeded while waiting for event at Timeout.setTimeout (/home/site/wwwroot/node_modules/puppeteer/lib/helper.js)
is Given Below:

I am trying to identify how to resolve this error. I have always had timeout issues with my sites and testing. It is not consistent and it is a different site everytime. I thought I resolved it by using the page.setDefaultTimeout(0); method – but now I am getting a different error that is pointing to lib/helper.js.

Unsure where to go from here. I want to extend the timeout to a few minutes so it does not error out under a minute when trying to load.

"ErrorMessage": "Timeout exceeded while waiting for event",
                "ErrorStack": "TimeoutError: Timeout exceeded while waiting for event
    at Timeout.setTimeout (/home/site/wwwroot/node_modules/puppeteer/lib/helper.js:196:24)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)
  -- ASYNC --
    at Page.<anonymous> (/home/site/wwwroot/node_modules/puppeteer/lib/helper.js:111:15)
    at Promise.all.endpoints.map.endpoint (/home/site/wwwroot/scripts/tests.js:162:19)
    at Array.map (<anonymous>)
    at Object.testStoreManagerLoad [as StoreManagerLoad] (/home/site/wwwroot/scripts/tests.js:161:15)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)"
const runTests = async (TestCases, customOpts = {}, log = console.log) => {
  const puppeteerOpts = {
    defaultViewport: {
      width: 1200,
      height: 850
    },
    args: ['--no-sandbox', '--disable-setuid-sandbox'],
    ...customOpts
  };
  const browser = await puppeteer.launch(puppeteerOpts);

  let page = await browser.newPage();

  page.setDefaultTimeout(0);
  
  const functionObj = {
    ClientContact: testClientContactForm,
    ClientSubmission: testClientSubmissionForm,
    TagRedemption: testTagRedemption,
    TagSubmission: testTagSubmissionForm,
    StoreManagerLoad: testStoreManagerLoad
  };

  for (const Case of TestCases) {
    try {
      log(`Started: ${Case.TestCaseName}`);
      await functionObj[Case.TestCaseType](Case, page);
      log(`Success: ${Case.TestCaseName}`);
      Case.Success = true;
    } catch (err) {
      log(`Failure: ${Case.TestCaseName}`);
      log(err.stack);
      Case.Success = false;
      Case.ErrorName = err.name;
      Case.ErrorMessage = err.message;
      Case.ErrorStack = err.stack;
    }

    if (!Case.Success) {
      if (Case.AlternateURL) {
        try {
          await functionObj[Case.TestCaseType](Case, page, true);
          log(`Alternate Success: ${Case.TestCaseName}`);
          Case.Success = true;
        } catch (altErr) {
          log(`Alternate Failure: ${Case.TestCaseName}`);
          log(altErr.stack);
          Case.ErrorName = altErr.name;
          Case.ErrorMessage = altErr.message;
          Case.ErrorStack = altErr.stack;
        }
      } else {
        page = await browser.newPage();
        try {
          await functionObj[Case.TestCaseType](Case, page);
          log(`Alternate Success: ${Case.TestCaseName}`);
          Case.Success = true;
        } catch (altErr) {
          log(`Alternate Failure: ${Case.TestCaseName}`);
          log(altErr.stack);
          Case.ErrorName = altErr.name;
          Case.ErrorMessage = altErr.message;
          Case.ErrorStack = altErr.stack;
        }
      }
    }
  }

  // Close the browser and exit the script
  await browser.close();

  return TestCases;
};