From eef1e3e87f9f2efdc002f1afe23f1b7df52a1ac9 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 16 May 2025 13:52:53 +0200 Subject: [PATCH] Ensure that the viewer clears the `workerPort` option when using "fake" workers Without this "fake" workers may be ignored in the API, which isn't really what you want when manually providing the `disableWorker=true` hash parameter. (Note that this requires the `pdfBugEnabled` option/preference to be set as well.) Also, after the changes in PR 19810 we can just load the "fake" worker directly in development mode and don't need to manually assign it to the global scope. --- web/app.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/web/app.js b/web/app.js index 0247762e3..6b7f95e1d 100644 --- a/web/app.js +++ b/web/app.js @@ -298,11 +298,12 @@ const PDFViewerApplication = { try { GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc"); - if (typeof PDFJSDev === "undefined") { - globalThis.pdfjsWorker = await import("pdfjs/pdf.worker.js"); - } else { - await __raw_import__(PDFWorker.workerSrc); - } + typeof PDFJSDev === "undefined" // eslint-disable-line no-unused-expressions + ? await import("pdfjs/pdf.worker.js") + : await __raw_import__(PDFWorker.workerSrc); + + // Ensure that the "fake" worker won't be ignored. + AppOptions.set("workerPort", null); } catch (ex) { console.error("_parseHashParams:", ex); }