Skip to content

Commit

Permalink
fix: race condition to restart printPdf
Browse files Browse the repository at this point in the history
  • Loading branch information
trev-dev committed Oct 10, 2024
1 parent 09cc48e commit 5a3d8eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/src/components/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand All @@ -519,8 +521,6 @@ async function printPdf(req, numOfRetries = 0) {
log.info(`printPdf :: retry count ${retryCount}`);
await printPdf(req, retryCount);
}
} finally {
await browser.close();
}
}

Expand Down

0 comments on commit 5a3d8eb

Please sign in to comment.