make two url loading timeouts options

This commit is contained in:
Kurt Moeller 2022-08-18 13:11:54 -07:00 committed by Antonin Stefanutti
parent 0c11545823
commit 8d581f4596
2 changed files with 18 additions and 2 deletions

View File

@ -126,6 +126,10 @@ Options:
-p <ms>, --pause <ms> Duration in milliseconds before each slide is exported [1000]
--load-pause <ms> Duration in milliseconds between the page has loaded
and starting to export slides [0]
--url-load-timeout <ms> Timeout in milliseconds to use when waiting for the initial
URL to load [60000]
--page-load-timeout <ms> Timeout in milliseconds to use when waiting for the slide deck
page to load [20000]
--screenshots Capture each slide as an image [false]
--screenshots-directory <dir> Screenshots output directory [screenshots]
--screenshots-size <size> Screenshots resolution, can be repeated [--size]

View File

@ -51,6 +51,18 @@ parser.script('decktape').options({
default : 0,
help : 'Duration in milliseconds between the page has loaded and starting to export slides',
},
urlLoadTimeout: {
full: 'url-load-timeout',
metavar: '<ms>',
default: 60000,
help: 'Timeout in milliseconds to use when waiting for the initial URL to load',
},
pageLoadTimeout: {
full: 'page-load-timeout',
metavar: '<ms>',
default: 20000,
help: 'Timeout in milliseconds to use when waiting for the slide deck page to load',
},
screenshots : {
default : false,
flag : true,
@ -242,8 +254,8 @@ process.on('unhandledRejection', error => {
.on('pageerror', error => console.log(chalk`\n{red Page error: ${error.message}}`));
console.log('Loading page', options.url, '...');
const load = page.waitForNavigation({ waitUntil: 'load', timeout: 20000 });
page.goto(options.url, { waitUntil: 'networkidle0', timeout: 60000 })
const load = page.waitForNavigation({ waitUntil: 'load', timeout: options.urlLoadTimeout });
page.goto(options.url, { waitUntil: 'networkidle0', timeout: options.pageLoadTimeout })
// wait until the load event is dispatched
.then(response => load
.catch(error => response.status() !== 200 ? Promise.reject(error) : response)