From 5db7a3cc886bea3cad1186516e72e679abecbe9d Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 17 Jun 2021 18:42:15 +0200 Subject: [PATCH] Ensure that `PDFScriptingManager.setDocument` handles failure when initializing the scripting-factory This way, we'll immediately clean-up in exactly the same way as the other failure code-paths in the `PDFScriptingManager.setDocument` method. --- web/pdf_scripting_manager.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/pdf_scripting_manager.js b/web/pdf_scripting_manager.js index c828e5ef0..85ac55cd4 100644 --- a/web/pdf_scripting_manager.js +++ b/web/pdf_scripting_manager.js @@ -96,7 +96,14 @@ class PDFScriptingManager { if (pdfDocument !== this._pdfDocument) { return; // The document was closed while the data resolved. } - this._scripting = this._createScripting(); + try { + this._scripting = this._createScripting(); + } catch (error) { + console.error(`PDFScriptingManager.setDocument: "${error?.message}".`); + + await this._destroyScripting(); + return; + } this._internalEvents.set("updatefromsandbox", event => { if (event?.source !== window) {