Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constantly getting Navigation Timeout Error #782

Closed
dustyhorizon opened this issue Sep 14, 2017 · 11 comments · Fixed by #887
Closed

Constantly getting Navigation Timeout Error #782

dustyhorizon opened this issue Sep 14, 2017 · 11 comments · Fixed by #887

Comments

@dustyhorizon
Copy link

Steps to reproduce

What steps will reproduce the problem?

const puppeteer = require('puppeteer');

(async() => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  page.on('console', (...args) => {
    for (let i = 0; i < args.length; ++i)
    console.log(`${i}: ${args[i]}`);
  });
  page.on('error', err => {
    console.log(err)
  })
  await page.goto('https://www.883jia.com.sg/');
  console.log(page.url());
  browser.close();
})()

What is the expected result?

Successful logging of page.url() then closure of the instance.

What happens instead?

0: JQMIGRATE: Migrate is installed, version 1.4.1
Error: Navigation Timeout Exceeded: 30000ms exceeded

Not really sure what happened, pretty new to this and all, do let me know what other information is needed. Would suspect that it is due to the JQMIGRATE message from the website though.

@paambaati
Copy link

The page just seems to be incredibly heavy. It has roughly 135 requests, and a majority of them being large images.

@kaushiksundar
Copy link

kaushiksundar commented Sep 14, 2017

@dustyhorizon

Pass timeout value in options. You can also use networkIdleTimout in case if you have gaps between your requests(ajax)

Doc

await page.goto('https://www.883jia.com.sg/', {
                networkIdleTimeout: 5000,
                waitUntil: 'networkidle',
                timeout: 3000000
            });

@aslushnikov
Copy link
Contributor

timeout option should accept the 0 value to disable timeout.
Let me know if anybody is interested in making a PR.

@sukrosono
Copy link
Contributor

@aslushnikov did you mean PR to the documentation?

@aslushnikov
Copy link
Contributor

@brutalcrozt PR to the codebase, you can't currently pass timeout: 0 to disable timeout for navigation

@sukrosono
Copy link
Contributor

@aslushnikov ok i got it, i might try that, But i really unfamiliar with the codebase, can you give me some direction? Maybe a couple file which involved with that action. 😄

@aslushnikov
Copy link
Contributor

@brutalcrozt: check out the lib/NavigatorWatcher for the actual code. Also, the Contributing.md has some tips on how to run and debug tests

@SashaDesigN
Copy link

SashaDesigN commented Oct 10, 2018

networkIdleTimeout is no longer supported in Puppeteer 1.8.0
But longer timeout solve my issue, thanks @kaushiksundar

@proton1k
Copy link

proton1k commented Jun 4, 2019

@dustyhorizon @SashaDesigN @aslushnikov
I'm handling this by simply catching the TimeoutError and recursively calling same function to reload the page several times before the app crashes. At least I'm able to drop some cases of occasional packets lost for unrecognizable network reasons. But this does not allow to handle specific errors. For example once I had a case with multiple images to be loaded by separate http requests and only one image failed to load (response was not returned) thus throwing 504 timeout.

@generalsystems
Copy link

To Solve this pass timeout:0 to the launch method
const browser = puppeteer.launch({timeout:0}) const page = await browser.newPage();
I hope that helps

@johnwaweru
Copy link

The best solution is to use a try catch block to catch the timeout error. If you're in a loop simply use continue if you wish to ignore the section you're in. Alternatively, as mentioned somewhere in the thread, you can recursively call the function you were executing but only for a finite number of times.

You can combine this with a healthy amount of a wait period before an error is thrown by using setDefaultNavigationTimeout. Here's an example:

const page = await browser.newPage();
// set navigation timeout to 4 minutes
await page.setDefaultNavigationTimeout(240000);
await page.goto("http://example.com");
for (let i = 0; i < count; i++) {
  try {
      // execute a block of code here
    } catch (e) {
      // continue with the loop if there's an error
      continue;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants