Skip to content

Commit 900479e

Browse files
committed
added wait time for signature to appear
1 parent eb885b5 commit 900479e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

backend/src/components/application.js

+20
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,26 @@ async function printPdf(req, numOfRetries = 0) {
456456
log.info('printPdf :: Waiting for signature field to appear');
457457
await page.waitForSelector('#signatureTextField', { visible: true });
458458

459+
let signatureContent = '';
460+
let signatureRetryCount = 0;
461+
462+
while (signatureRetryCount < 5) {
463+
signatureContent = await page.$eval('#signatureTextField', (el) => el.value.trim());
464+
465+
if (signatureContent) {
466+
log.info(`printPdf :: Signature field has content: "${signatureContent}"`);
467+
break;
468+
}
469+
470+
signatureRetryCount++;
471+
log.warn(`printPdf :: WARN: Signature field is empty (Attempt ${signatureRetryCount}/5). Retrying in 2s...`);
472+
await sleep(2000);
473+
}
474+
475+
if (!signatureContent) {
476+
throw new Error('printPdf :: ERROR: No signature found after 5 retries');
477+
}
478+
459479
log.info('printPdf :: Begin Generating PDF');
460480
const pdfStartTime = Date.now();
461481
const pdfBuffer = await page.pdf({

0 commit comments

Comments
 (0)