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

page load timeout config #38

Open
RPing opened this issue Jun 19, 2020 · 1 comment
Open

page load timeout config #38

RPing opened this issue Jun 19, 2020 · 1 comment

Comments

@RPing
Copy link

RPing commented Jun 19, 2020

Hi, timesnap is really awesome!

Here is a problem that I encounter.
I want to tune page load timeout (puppeteer navigation timeout defaults 30s), like page.setDefaultTimeout or page.setDefaultNavigationTimeout, so I put them into timecut preparePage. But it doesn't work.

It seems that page.goto is earlier than preparePage, any suggestion?

@tungs
Copy link
Owner

tungs commented Jun 29, 2020

An inelegant approach is to use the undocumented configurations config.browser or config.launcher with a configured puppeteer browser with custom launch options to set the timeout.

config.browser

For Example:

const puppeteer = require('puppeteer');
const timesnap = require('timesnap');
timesnap({
  browser: puppeteer.launch({
    timeout: 120000 // can use 0 to disable timeout
  })
});

Note that this approach overrides any other set launch configurations, including those set by config.quiet, config.logToStdErr, config.headless, config.executablePath, and config.launchArguments. If you are using those configuration options, see these lines if you need to reenable them.

config.launcher

Alternatively you can use config.launcher to automatically use the previously set launch options:

const puppeteer = require('puppeteer');
const timesnap = require('timesnap');
timesnap({
  launcher: function (launchOptions) {
    return puppeteer.launch(Object.assign({}, launchOptions, {
      timeout: 120000 // can use 0 to disable timeout
    }));
  }
});

Looking at this now, it looks like it would be beneficial to allow custom launch options (not to be confused with config.launchArguments).

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

No branches or pull requests

2 participants