mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Ensure that PDFDocument.checkFirstPage
waits for cleanup to complete (PR 10392 follow-up)
Given how this method is currently used there shouldn't be any fonts loaded at the point in time where it's called, but it does seem like a bad idea to assume that that's always going to be the case. Since `PDFDocument.checkFirstPage` is already asynchronous, it's easy enough to simply await `Catalog.cleanup` here. (The patch also makes a tiny simplification in a loop in `Catalog.cleanup`.)
This commit is contained in:
parent
514b500a6c
commit
a02122e984
2 changed files with 4 additions and 5 deletions
|
@ -664,13 +664,13 @@ class PDFDocument {
|
|||
}
|
||||
|
||||
checkFirstPage() {
|
||||
return this.getPage(0).catch((reason) => {
|
||||
return this.getPage(0).catch(async (reason) => {
|
||||
if (reason instanceof XRefEntryException) {
|
||||
// Clear out the various caches to ensure that we haven't stored any
|
||||
// inconsistent and/or incorrect state, since that could easily break
|
||||
// subsequent `this.getPage` calls.
|
||||
this._pagePromises.length = 0;
|
||||
this.cleanup();
|
||||
await this.cleanup();
|
||||
|
||||
throw new XRefParseException();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue