From 357ff4afde38d033db6768a38638a11bd88bf05e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 10 Feb 2025 16:19:41 +0100 Subject: [PATCH] Catch and ignore any errors during auto-linking parsing (PR 19110 follow-up) While investigating a bug, that I've not yet had time to fully investigate and report, I found that if there's ever an error thrown from the `Autolinker` class it'll prevent the annotationEditorLayer from rendering *and* the renderTask itself will be treated as having failed. --- web/pdf_page_view.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index f4605b141..d91fffb79 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -1112,12 +1112,17 @@ class PDFPageView { await this.#renderAnnotationLayer(); if (this.#enableAutoLinking) { - await textLayerPromise; - this.annotationLayer?.injectLinkAnnotations({ - inferredLinks: Autolinker.processLinks(this), - viewport: this.viewport, - structTreeLayer: this.structTreeLayer, - }); + try { + await textLayerPromise; + + this.annotationLayer?.injectLinkAnnotations({ + inferredLinks: Autolinker.processLinks(this), + viewport: this.viewport, + structTreeLayer: this.structTreeLayer, + }); + } catch (ex) { + console.error("enableAutoLinking:", ex); + } } }