Node.js puppeteer - How to set navigation timeout?

Philipp M picture Philipp M · Sep 4, 2018 · Viewed 50.2k times · Source

I'm using node.js and puppeteer to get some data. Some of the files I'm opening are quite large ... and then I get an error:

Error:

our error { TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
    at Promise.then (/project/node_modules/puppeteer/lib/NavigatorWatcher.js:74:21)
    at <anonymous> name: 'TimeoutError' }

How can I ignore it or set a higher timeout?

That's my script:

await page.goto('url'+tableCell04Val, {waitUntil: 'load'});

Answer

Jay Gould picture Jay Gould · Sep 4, 2018

You can use timeout: 0 to disabled timeout errors if you're loading a heavy page.

Use it in your page.goto like:

await page.goto('url'+tableCell04Val, {waitUntil: 'load', timeout: 0});

You can see the PR made to Pupeteer here which added the change, along with documentation and the unit tests that implement it.