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

How to handle the timeout error? #336

Open
gajus opened this issue Dec 25, 2018 · 2 comments
Open

How to handle the timeout error? #336

gajus opened this issue Dec 25, 2018 · 2 comments
Labels

Comments

@gajus
Copy link

gajus commented Dec 25, 2018

What is the current behavior?

Getting unhandled exception:

{ Error: Navigation Timeout Exceeded: 30000ms exceeded
    at Promise.then (/.../node_modules/puppeteer/lib/NavigatorWatcher.js:73:21)
  options:
   { maxDepth: 1,
     priority: 0,
     delay: 0,
     retryCount: 1,
     retryDelay: 10000,
     timeout: 30000,
     jQuery: true,
     browserCache: false,
     skipDuplicates: true,
     depthPriority: true,
     obeyRobotsTxt: true,
     followSitemapXml: false,
     skipRequestedRedirect: false,
     cookies: null,
     screenshot: null,
     viewport: null,
     evaluatePage:
      "(() => {\n      return {\n        title: $('title').text()\n      };\n    })()",
     url: 'https://foo.bar/' },
  depth: 1,
  previousUrl: null }

Despite configured onError handler:

const crawl = async (startUrl: string) => {
  log.debug('beginning to crawl %s', startUrl);

  const crawler = await launchCrawler({
    browserCache: false,
    evaluatePage: () => {
      return {
        title: $('title').text()
      };
    },
    headless: true,
    onError: (error) => {
      console.log(error);
    },
    onSuccess: (result) => {
      console.log(result);
    },
    retryCount: 1
  });

  crawler.queue(startUrl);

  await crawler.onIdle();
  await crawler.close();
};

What is the expected behavior?

I am expecting that the onError handler would catch the timeout error.

What is the motivation / use case for changing the behavior?

Otherwise, there is no documented way to handle a timeout.

Please tell us about your environment:

  • Version: ^1.8.0
  • Platform / OS version: OSX
  • Node.js version: v11.3.0
@gajus
Copy link
Author

gajus commented Dec 25, 2018

This happens when some of the resources on the initial page timeout, e.g. CSS.

There should be an option permitting ignoring loading of those resources.

@kulikalov
Copy link
Contributor

@gajus thanks for the suggestion! Good point! Do you consider creating a PR?

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

No branches or pull requests

2 participants