Skip to content

Commit

Permalink
bug(pdf): Don't fail PDF if broken link
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Balmos <[email protected]>
  • Loading branch information
abalmos committed Nov 21, 2024
1 parent 257b368 commit 982a074
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.1.cjs
16 changes: 10 additions & 6 deletions service/src/zd/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,15 @@ export async function generateTicketPdf(
type === 'err' &&
// Some tickets have real, but broken links. Don't count these as errors
!message.text().includes('the server responded with a status of 404') &&
!message.text().includes('net::ERR_TOO_MANY_REDIRECTS')
!message.text().includes('net::ERR_TOO_MANY_REDIRECTS') &&
!message.text().includes('net::ERR_NAME_NOT_RESOLVED')
) {
puppeteerErrors.push(message.text(), 'HERE1');
puppeteerErrors.push(message.text());
}
})
.on('pageerror', (error) => {
log.warn({ error }, `[Puppeteer] ${error.name}: ${error.message}.`);
puppeteerErrors.push(error.message, 'HERE2');
puppeteerErrors.push(error.message);
})
.on('requestfailed', (request) => {
log.warn(
Expand All @@ -181,8 +182,11 @@ export async function generateTicketPdf(
const errorText = request.failure()?.errorText ?? 'Request failure';

// Some tickets have real, but broken links. Don't count these as errors
if (errorText !== 'net::ERR_TOO_MANY_REDIRECTS') {
puppeteerErrors.push(errorText, 'HERE3');
if (
errorText !== 'net::ERR_TOO_MANY_REDIRECTS' &&
errorText !== 'net::ERR_NAME_NOT_RESOLVED'
) {
puppeteerErrors.push(errorText);
}
});

Expand Down Expand Up @@ -214,7 +218,7 @@ export async function generateTicketPdf(
});
} catch (error) {
log.trace({ error }, `Credentialed API request to ZenDesk failed.`);
puppeteerErrors.push(`${error}`, 'HERE4');
puppeteerErrors.push(`${error}`);
await request.abort('failed');
}
} else {
Expand Down

0 comments on commit 982a074

Please sign in to comment.