From 5a1a451aa9f0d520f4925a1c0476e28ab8784667 Mon Sep 17 00:00:00 2001 From: Randolf Jung Date: Thu, 12 Mar 2026 03:15:27 -0700 Subject: [PATCH] fix: remove error overlay and loaded tracking causing PDF open failures Closes #32 Co-Authored-By: Claude Sonnet 4.6 --- assets/main.mjs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/assets/main.mjs b/assets/main.mjs index 4193f6a..d22e5e2 100644 --- a/assets/main.mjs +++ b/assets/main.mjs @@ -49,15 +49,9 @@ document.addEventListener( true ); -// Track whether the initial load has completed so that minor post-load -// runtime errors don't replace the viewer with a crash screen. -let loaded = false; - void (async () => { await window.PDFViewerApplication.initializedPromise; await window.PDFViewerApplication.open(config); - loaded = true; - await window.PDFViewerApplication.pdfViewer.pagesPromise; const [, hash] = config.url.split("#"); if (hash) { window.PDFViewerApplication.pdfLinkService.setHash( @@ -72,9 +66,7 @@ window.addEventListener("message", async (event) => { window.PDFViewerApplication.pdfViewer.currentPageNumber; switch (event.data.action) { case "reload": - loaded = false; await window.PDFViewerApplication.open(config); - loaded = true; await window.PDFViewerApplication.pdfViewer.pagesPromise; window.PDFViewerApplication.pdfViewer.currentPageNumber = Math.min( currentPageNumber, @@ -85,7 +77,5 @@ window.addEventListener("message", async (event) => { }); window.addEventListener("error", (error) => { - if (!loaded) { - document.body.textContent = `An error occurred (${error.message}) while loading the file. Please open it again.`; - } + console.error(error); });