Skip to content

-t --timeout isn't implemented?

Hi,

I think -t --timeout isn't implemented?, I had a look in the code and couldn't find it being used (I'm new to NodeJs so that doesn't mean much).

Also the timeout is a bit ambiguous, is it the max time the script can run or a parameter passed to Puppeteer like ( puppeteer.launch([timeout <number>]) ) ?

As pagedjs-cli will just hang if the page to render has a JS error or an rendering issue causing an infinite loop I think it's a good idea to have a "global" timeout.

In my use case I need to kill the script as it's being launched from PHP and the PHP script hangs until the pagedjs-cli hasn't finished. Also if the browser is closed the pagedjs-cli and Chromium processes are left running (tested on Windows 10).

This works and (on Windows) kills the Chromium processes too.

// Failsafe exit!
if ( program.timeout !== undefined && parseInt(program.timeout ) > 0 )
{
    setTimeout(() => {
        process.exit(1);
    }, parseInt(program.timeout ) );
}