116117bot icon indicating copy to clipboard operation
116117bot copied to clipboard

Puppeteer TimeoutError: Timeout exceeded while waiting for event

Open FloRinke opened this issue 3 years ago • 7 comments

When querying the URL with Vermittlungscode, every second to third time this fails with a TimeoutError:

TimeoutError: Timeout exceeded while waiting for event
    at Timeout.<anonymous> (/app/node_modules/puppeteer/lib/cjs/puppeteer/common/helper.js:120:28)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)

Im running current master with this call (redacted for privacy):

sudo docker run -it --name 116117bot -e URLS="https://123-iz.impfterminservice.de/impftermine/suche/XXXX-XXXX-XXXX/12345" 116117bot

Please tell if I can assisst in debugging, unfortunately JavaScript is not my strong suit (else I'd prefer sending PRs over Issues).

FloRinke avatar Feb 28 '21 14:02 FloRinke

I have a feeling this issue masks available appointments.... Just noticed that often after seeing this issue, in the next successful run the hash has changed.

FloRinke avatar Mar 01 '21 07:03 FloRinke

Thank you! Unfortunately, I won't have time to look into it over the next few days – please feel free to continue posting if you make any new discoveries. Otherwise, I can always recommend running the bot in non-headless mode and observing what happens, ideally with some console.log("Hello world.") statements in the flow.

joshuajung avatar Mar 01 '21 08:03 joshuajung

I seams that by increasing this timeout value to 30 * 1000 instead of 10 * 1000 solves the problem:

await page.waitForResponse(
        (res) => res.url().indexOf("terminpaare") !== -1,
        { timeout: 10 * 1000 }
);

CodeSmolder avatar Mar 07 '21 15:03 CodeSmolder

I am attaching code snippet. You can use that and modify according to your scenario. It helps in dealing with timeout error related issues.

const puppeteer = require("puppeteer"); const { scrollPageToBottom } = require('puppeteer-autoscroll-down')

async function scrape () {

const browser = await puppeteer.launch({headless: false});
const page =  await browser.newPage();

await page.goto("https://twitter.com/elonmusk", {waitUntil: "networkidle2"});

let isLoadingAvailable = true // Your condition-to-stop

while (isLoadingAvailable) {
    try{
        await scrollPageToBottom(page, { size: 250 , delay: 500})
        await page.waitForResponse(
        response => response.url() === 'https://twitter.com/elonmusk' && response.status() === 200
        )

    } catch (ex) {
        continue;
        
    }
    isLoadingAvailable = false // Update your condition-to-stop value
}

console.log("Loading done")
await browser.close();

}; scrape();

furqan4545 avatar Apr 23 '22 16:04 furqan4545

This work in 100% of the cases for me. You can check it out.

await page.waitForSelector( "", { visible: true, waitUntil: "load", waitUntil: "networkidle0", waitUntil: "domcontentloaded", waitUntil: "networkidle2", timeout: 10 * 1000, } );

louviralok avatar Mar 28 '23 20:03 louviralok

I have exactly the same error with the latest version of puppeteer (21.5.0). Approximately one time out of 2, the error is impossible to catch with the try catch block, and the script ends by crashing.

/home/.../node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:59 void this.terminate(new Errors_js_1.TimeoutError(Waiting failed: ${options.timeout}ms exceeded)); ^

TimeoutError: Waiting failed: 15000ms exceeded at Timeout. (/home/.../node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:59:37) at listOnTimeout (node:internal/timers:564:17) at process.processTimers (node:internal/timers:507:7)

try {	
  const pages = await currentBrowserInstance.browser.pages();
  const page = pages[0];
  await page.setViewport({ width: 100, height: 100 });
  const watchDog = page.waitForFunction('!!window.DRAW_FINISH', {timeout: timeout});
  await page.goto(backendURL, {timeout: timeout});
  await watchDog;
}
catch(e) {
  console.error(e);
}

flexeo avatar Nov 09 '23 04:11 flexeo

Hi, I am facing a similar issue:

https://github.com/oppia/oppia/actions/runs/9994971012/job/27627319315

Akhilesh-max avatar Jul 18 '24 17:07 Akhilesh-max