diff --git a/web/app.js b/web/app.js index 27dc2935f..7bc296bd4 100644 --- a/web/app.js +++ b/web/app.js @@ -1383,14 +1383,23 @@ const PDFViewerApplication = { onePageRendered.then(() => { pdfDocument.getOutline().then(outline => { + if (pdfDocument !== this.pdfDocument) { + return; // The document was closed while the outline resolved. + } this.pdfOutlineViewer.render({ outline, pdfDocument }); }); pdfDocument.getAttachments().then(attachments => { + if (pdfDocument !== this.pdfDocument) { + return; // The document was closed while the attachments resolved. + } this.pdfAttachmentViewer.render({ attachments }); }); // Ensure that the layers accurately reflects the current state in the // viewer itself, rather than the default state provided by the API. pdfViewer.optionalContentConfigPromise.then(optionalContentConfig => { + if (pdfDocument !== this.pdfDocument) { + return; // The document was closed while the layers resolved. + } this.pdfLayerViewer.render({ optionalContentConfig, pdfDocument }); }); if (