I thought I had a pretty good catch to find those rare timeouts that I get from puppeteer, but some how this timeout is not caught by any of them - my question is why?
Here is the code:
var readHtml = (url) => {
return new Promise( async (resolve,reject)=> {
var browser = await puppeteer.launch()
var page = await browser.newPage()
await page.waitForSelector('.allDataLoaded')
.then(() => {
console.log ("Finished reading: " + url)
return resolve("COOL");
})
.catch((err) => {
console.log ("Timeout or other error: ", err)
return resolve("TRYAGAIN");
});
})}
And here is the error....
(node:23124) UnhandledPromiseRejectionWarning: Error: Navigation Timeout Exceeded: 30000ms exceeded at Promise.then
(node:23124) UnhandledPromiseRejectionWarning:
Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
I did some research which said it might be because there are some urls not yet finished inside the puppeteer newPage()
But how come this does not get cough by my .catch?
I need it to "TRYAGAIN" in case it fails for what ever reason. Now it just stops with the error and does nothing.