Skip to content

Commit

Permalink
Revoke the blob-URLs used during printing in PDFPrintService
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffleupagus committed Aug 23, 2024
1 parent 502a429 commit 6a1b1ae
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions web/pdf_print_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 6a1b1ae

Please sign in to comment.