0

I have a Puppeteer script which loads a URL and then does something with the response. Sometimes the page times out, but I would like my script to continue with whatever the current state of the page is. I have already tried waitUntil: 'networkidle2', but sometimes it still times out.

Waiting until the load isn't good enough because the images may not be loaded, and domcontentloaded also doesn't work because the page may time out.

Ideally I could just use networkidle2, up to a maximum of (say) 15 seconds, and if the page still hasn't loaded, just continue and use the page response as it is. Can this be done?

Thanks!

Matt Parlane
  • 453
  • 2
  • 11
  • Please share the site, code so far and expected result. Just because you need images doesn't mean you can't use "load" or "domcontentloaded". DCL is the least-strict and therefore least likely to time out. I generally use DCL for almost everything. See [this answer](https://stackoverflow.com/a/49233383/6243352) for example. Also, many sites have additional requests you don't care about that slow things up considerably, like analytics and ad stuff--you might try blocking those entirely. If you want to catch a nav timeout, you can, but that's unlikely to be the best approach. – ggorlen Oct 28 '22 at 04:47

0 Answers0