1

Basically I have a basic Puppeteer code which works great.

But the website I'm using sometimes either loads slower, or doesn't select a selector.

In result, this throws a timeout error:

(node:17340) UnhandledPromiseRejectionWarning: TimeoutError: waiting for selector `.item-price` failed: timeout 30000ms exceeded

And I need to close the CMD and start the task again. Which is quite frustrating when you are trying of running 20-30 of those.

My question is, is there a command, that whenever the TimeoutError occurs, it would restart the process again?

I'm not a code, but I guess I would need to enter the line, from which it should start again?

Any help would be appreciated.

P.S. when the error occurs, it doesn't close the headless browser, so I guess it should be possible?

robert0
  • 435
  • 2
  • 12
  • 1
    Maybe `page.waitForSelector(selector, { timeout: 0 })` would suffice? So that there will be no timeout error at all. – vsemozhebuty May 08 '21 at 18:23
  • 1
    hey vsemozhebuty! thanks, I think that's exactly what I need. I'm looking at this thread right now: https://stackoverflow.com/questions/57471687/how-do-you-wait-for-a-selector-but-only-for-a-specific-time-period-in-puppeteer and trying to figure out how to implement in my code. Thanks for pointing on the right track! – robert0 May 08 '21 at 20:46

0 Answers0