Skip to content

Commit

Permalink
Merge pull request #559 from bcgov/ccfri-3694-debug-puppeteer
Browse files Browse the repository at this point in the history
fix: dead browser instance after one PDF run
  • Loading branch information
trev-dev authored Oct 30, 2024
2 parents 5ce1b38 + ad53564 commit 6bee45c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/src/util/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ let browser = null;
async function getBrowserContext() {
try {
if (browser instanceof puppeteer.Browser && browser.process() !== null) {
return browser;
log.info('Puppeteer :: getBrowserContext reusing browser process');
return browser.createBrowserContext();
}
// To debug locally add {headless: false, devtools: true} in options
// make sure they are boolean and not string
Expand Down Expand Up @@ -57,6 +58,7 @@ async function closeBrowser() {
const pages = await browser.pages();
if (pages.length === 1) {
await browser.close();
browser = null;
} else {
log.warn('Puppeteer :: closeBrowser was called with pages open');
}
Expand Down

0 comments on commit 6bee45c

Please sign in to comment.