From 21798293720ce5ba279f247620bab5bf897c44cf Mon Sep 17 00:00:00 2001 From: powerivq Date: Tue, 28 May 2024 18:16:55 -0700 Subject: [PATCH] WIP Upgrade dependencies for security issues --- .../spec/helpers/validatorInstance.js | 1 - .../page-experience/lib/PageDataGatherer.js | 21 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/optimizer/spec/helpers/validatorInstance.js b/packages/optimizer/spec/helpers/validatorInstance.js index b4a797c77..e93fa05af 100644 --- a/packages/optimizer/spec/helpers/validatorInstance.js +++ b/packages/optimizer/spec/helpers/validatorInstance.js @@ -6,7 +6,6 @@ let instance = null; module.exports = { get: () => { if (!instance) { - console.error('Validator instance created: ' + path.join(__dirname, 'validator.js')); instance = validator.getInstance(path.join(__dirname, 'validator.js')); } return instance; diff --git a/packages/page-experience/lib/PageDataGatherer.js b/packages/page-experience/lib/PageDataGatherer.js index 7035d715b..07bb69996 100644 --- a/packages/page-experience/lib/PageDataGatherer.js +++ b/packages/page-experience/lib/PageDataGatherer.js @@ -58,20 +58,16 @@ class PageAnalyzer { throw new Error('Puppeteer not running, please call `start` first.'); } const {page, remoteStyles, responsePromise} = await this.setupPage(); - try { - await page.goto(url, {waitUntil: 'load'}); + await page.goto(url, {waitUntil: 'load'}); - const response = await responsePromise; - if (!response) { - throw new Error('Failed loading url', url); - } - const {html, headers} = response; - return await this.gatherPageData(page, {remoteStyles, html, headers}); - } finally { - if (page) { - page.close(); - } + const response = await responsePromise; + if (!response) { + throw new Error('Failed loading url', url); } + const {html, headers} = response; + const data = await this.gatherPageData(page, {remoteStyles, html, headers}); + await page.close(); + return data; } /** @@ -80,6 +76,7 @@ class PageAnalyzer { async shutdown() { try { await this.browser.close(); + this.browser = null; } catch (e) { console.log(e); }