Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Puppeteer "TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded" when running from Crontab

I have a Node.JS automation which uses Puppeteer and loads some URLs as part of the process. My code is pretty basic and uses just the very basic functions as documented in the package documentation.

The automation is scheduled to run with crontab every 15 minutes, but for some reasons run after run I am facing a TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded Error and the page is not loaded successfully. When I run the exact same code manually everything works well and the page load pretty fast.

Can someone think of anything that can the reason for this strange behavior?

Thanks

like image 858
GMe Avatar asked Oct 19 '19 09:10

GMe


1 Answers

You can add an option page.setDefaultNavigationTimeout(0) after puppeteer.launch().

    const browser = await puppeteer.launch()
    const page = await browser.newPage()

    page.setDefaultNavigationTimeout(0)

Hope this works fine.

like image 164
Edi Imanto Avatar answered Sep 21 '22 00:09

Edi Imanto