Skip to content

Commit

Permalink
Add ContinuousServerClient.js, phetsims/aqua#143
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jun 1, 2022
1 parent fd66d15 commit 34bcd56
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions js/common/puppeteerLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = async function( url, options ) {

evaluate: null, // {function|null}

resolvePageErrors: true, // resolve when the page errors
waitAfterLoad: 5000, // milliseconds
allowedTimeToLoad: 40000, // milliseconds
puppeteerTimeout: 30000 // milliseconds
Expand All @@ -49,13 +50,15 @@ module.exports = async function( url, options ) {
await sleep( options.waitAfterLoad );
resolve( options.evaluate && !page.isClosed() ? await page.evaluate( options.evaluate ) : null );
} );
page.on( 'error', msg => {
winston.info( `puppeteer error: ${msg}` );
resolve( new Error( msg ) );
page.on( 'error', error => {
winston.info( `puppeteer error: ${error}` );
resolve( new Error( error ) );
} );
page.on( 'pageerror', msg => {
winston.info( `puppeteer pageerror: ${msg}` );
resolve( new Error( msg ) );
page.on( 'pageerror', error => {
winston.info( `puppeteer pageerror: ${error}` );
if ( options.resolvePageErrors ) {
resolve( new Error( error ) );
}
} );
( async () => {
await sleep( options.allowedTimeToLoad );
Expand Down

0 comments on commit 34bcd56

Please sign in to comment.