From 7aab28e1da38921d4bf7520718f17c91c096c002 Mon Sep 17 00:00:00 2001 From: Kata Martin Date: Fri, 15 Aug 2025 09:42:10 -0400 Subject: [PATCH 1/2] Add logging when PDF fails to load --- app/preprint/[id]/preprint-viewer.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/preprint/[id]/preprint-viewer.tsx b/app/preprint/[id]/preprint-viewer.tsx index a4e780f..a5fcb74 100644 --- a/app/preprint/[id]/preprint-viewer.tsx +++ b/app/preprint/[id]/preprint-viewer.tsx @@ -21,6 +21,7 @@ import { AuthorsList } from '../../../components' import { Deposition } from '../../../types/zenodo' import { fetchDataDeposition, fetchPreprintIdentifier } from '../../../actions' import ErrorOrTrack from './error-or-track' +import { alertOnError } from '../../../actions/server-utils' pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs` @@ -111,10 +112,6 @@ const PreprintViewer = ({ }) }, [track, preprint.pk, submissionType]) - const onDocumentLoadSuccess = (pdf: PDFDocumentProxy): void => { - setPdf(pdf) - } - useEffect(() => { if (pdf && !hidePdfOutline) { pdf.getOutline().then(setPdfOutline).catch(console.error) @@ -201,7 +198,16 @@ const PreprintViewer = ({
setPdf(pdf)} + onLoadError={(error) => + alertOnError({ + endpoint: preprint.versions[0].public_download_url, + status: 'n/a', + statusText: 'unknown', + method: 'GET', + apiError: error.message, + }) + } loading={ Date: Fri, 15 Aug 2025 09:51:23 -0400 Subject: [PATCH 2/2] Add check against hostname --- app/preprint/[id]/preprint-viewer.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/preprint/[id]/preprint-viewer.tsx b/app/preprint/[id]/preprint-viewer.tsx index a5fcb74..a430bf0 100644 --- a/app/preprint/[id]/preprint-viewer.tsx +++ b/app/preprint/[id]/preprint-viewer.tsx @@ -200,13 +200,15 @@ const PreprintViewer = ({ file={preprint.versions[0].public_download_url} onLoadSuccess={(pdf: PDFDocumentProxy) => setPdf(pdf)} onLoadError={(error) => - alertOnError({ - endpoint: preprint.versions[0].public_download_url, - status: 'n/a', - statusText: 'unknown', - method: 'GET', - apiError: error.message, - }) + window.location.hostname.includes('cdrxiv.org') + ? alertOnError({ + endpoint: preprint.versions[0].public_download_url, + status: 'n/a', + statusText: 'unknown', + method: 'GET', + apiError: error.message, + }) + : undefined } loading={