From 5a3d8eb67571cc68041b2b9811a215c530215483 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Thu, 10 Oct 2024 09:57:05 -0700 Subject: [PATCH] fix: race condition to restart printPdf --- backend/src/components/application.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/components/application.js b/backend/src/components/application.js index 416863c04..7a80c0c4f 100644 --- a/backend/src/components/application.js +++ b/backend/src/components/application.js @@ -504,11 +504,13 @@ async function printPdf(req, numOfRetries = 0) { await postChangeRequestSummaryDocument(payload); } - + browser.close(); return payload; } catch (e) { log.error(e); + if (browser.process() !== null) { await browser.close(); } + if (numOfRetries >= 3) { log.info('printPdf :: maximum number of retries reached'); log.error(`printPdf :: unable to save pdf for application id ${req.params.applicationId}`); @@ -519,8 +521,6 @@ async function printPdf(req, numOfRetries = 0) { log.info(`printPdf :: retry count ${retryCount}`); await printPdf(req, retryCount); } - } finally { - await browser.close(); } }