From 0ac7ccffd7aab7ca469346a4eb77187b632eafd2 Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Tue, 1 Nov 2022 15:13:01 -0600 Subject: [PATCH] minor code tweaks, https://github.com/phetsims/aqua/issues/150 --- js/common/puppeteerLoad.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/js/common/puppeteerLoad.js b/js/common/puppeteerLoad.js index 0082e6b3..39b0888c 100644 --- a/js/common/puppeteerLoad.js +++ b/js/common/puppeteerLoad.js @@ -77,22 +77,16 @@ module.exports = async function( url, options ) { timeout: options.puppeteerTimeout } ); const result = await promise; - await page.close(); + !page.isClosed() && await page.close(); // If we created a temporary browser, close it - if ( ownsBrowser ) { - await browser.close(); - } + ownsBrowser && await browser.close(); return result; } catch( e ) { page && !page.isClosed() && await page.close(); - - // If we created a temporary browser, close it - if ( ownsBrowser ) { - await browser.close(); - } + ownsBrowser && await browser.close(); return e; } };