From 43ce1bb4913f944a79b450b2d4a77afb266c7872 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 9 May 2026 12:22:10 +0200 Subject: [PATCH] [api-major] Remove the `PDFDocumentProxy.prototype.destroy` method This is a left-over from very old code, which pre-dates the introduction of the `PDFDocumentLoadingTask` and it's nothing more than an alias for its `destroy` method. Given that `PDFDocumentProxy` already provides a way to access the underlying `PDFDocumentLoadingTask` instance, it shouldn't be necessary to have an alias for one of its methods. *Please note:* For any existing code relying on the removed method, updating it should be as simple as replacing `pdfDocument.destroy()` with `pdfDocument.loadingTask.destroy()`. --- [1] If the `PDFDocumentProxy` class was added today, there's no chance that it'd include a `destroy` method. --- src/display/api.js | 7 ------- test/driver.js | 2 +- test/unit/api_spec.js | 2 +- web/internal/debugger.js | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index dfbd57f79..005d1ec5a 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -1026,13 +1026,6 @@ class PDFDocumentProxy { return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa); } - /** - * Destroys the current document instance and terminates the worker. - */ - destroy() { - return this.loadingTask.destroy(); - } - /** * @param {RefProxy} ref - The page reference. * @returns {number | null} The page number, if it's cached. diff --git a/test/driver.js b/test/driver.js index 8533c7b40..7e098f7e0 100644 --- a/test/driver.js +++ b/test/driver.js @@ -969,7 +969,7 @@ class Driver { // Wipe out the link to the pdfdoc so it can be GC'ed. for (const task of [this.currentTask, ...this.taskQueue]) { if (task?.pdfDoc) { - destroyedPromises.push(task.pdfDoc.destroy()); + destroyedPromises.push(task.pdfDoc.loadingTask.destroy()); delete task.pdfDoc; } } diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index 7245ffa0c..27ee9007b 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -3203,7 +3203,7 @@ describe("api", function () { params.url = url.href; loadingTask = getDocument(params); return loadingTask.promise - .then(pdf => pdf.destroy()) + .then(() => loadingTask.destroy()) .then( function () { expect(expectSuccess).toEqual(true); diff --git a/web/internal/debugger.js b/web/internal/debugger.js index 7b7f4d786..6330fd492 100644 --- a/web/internal/debugger.js +++ b/web/internal/debugger.js @@ -95,7 +95,7 @@ async function openDocument(source, name) { if (pdfDoc) { pageView.reset(); - await pdfDoc.destroy(); + await pdfDoc.loadingTask.destroy(); pdfDoc = null; }