joshuajung / 116117bot

A proof of concept bot, checking impfterminservice.de for available COVID-19 vaccination appointments.
MIT License
34 stars 16 forks source link

Puppeteer TimeoutError: Timeout exceeded while waiting for event #10

Open FloRinke opened 3 years ago

FloRinke commented 3 years ago

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 commented 3 years ago

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.

joshuajung commented 3 years ago

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.

CodeSmolder commented 3 years ago

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 }
);
furqan4545 commented 2 years ago

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();

louviralok commented 1 year ago

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, } );

flexeo commented 1 year ago

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);
}
Akhilesh-max commented 4 months ago

Hi, I am facing a similar issue:

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