diff --git a/web/pdf_print_service.js b/web/pdf_print_service.js index 7017345a04f53..45106ca30788b 100644 --- a/web/pdf_print_service.js +++ b/web/pdf_print_service.js @@ -199,10 +199,18 @@ class PDFPrintService { wrapper.append(img); this.printContainer.append(wrapper); - return new Promise(function (resolve, reject) { - img.onload = resolve; - img.onerror = reject; - }); + const { promise, resolve, reject } = Promise.withResolvers(); + img.onload = resolve; + img.onerror = reject; + + promise + .catch(() => { + // Avoid "Uncaught promise" messages in the console. + }) + .then(() => { + URL.revokeObjectURL(img.src); + }); + return promise; } performPrint() {