diff --git a/backend/Dockerfile b/backend/Dockerfile index 2b50d4d11..adcad2392 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM artifacts.developer.gov.bc.ca/docker-remote/node:20.18.0-alpine3.20 +FROM artifacts.developer.gov.bc.ca/docker-remote/node:20.18.0-alpine3.19 ENV NPM_CONFIG_CACHE /tmp/npm RUN mkdir -p /logs \ diff --git a/backend/src/util/browser.js b/backend/src/util/browser.js index 6422c4c44..111c893d1 100644 --- a/backend/src/util/browser.js +++ b/backend/src/util/browser.js @@ -38,7 +38,7 @@ async function getBrowserContext() { browserProcess .on('close', code => log.info(`Puppeteer :: browser process closed, status: ${code}`)); - return browser.createBrowserContext(); + return await browser.createBrowserContext(); } catch (e) { log.error('Puppeteer :: Browser process could not be retrieved', e); return null; @@ -49,7 +49,13 @@ async function getBrowserContext() { * Gracefully close the browser and all of its pages/contexts. */ async function closeBrowser() { - if (browser.pages().length === 0) { + if (browser === null) { + log.warn('Puppeteer :: closeBrowser called with null browser'); + return; + } + + const pages = await browser.pages(); + if (pages.length === 1) { await browser.close(); } else { log.warn('Puppeteer :: closeBrowser was called with pages open');