Skip to content

Commit

Permalink
Don't dispatch REJECT action to resolver when loadingTask was destroyed
Browse files Browse the repository at this point in the history
loadingTask.promise throws after loadingTask.destroy() is called, and we call loadingTask.destroy() to destroy worker once it loaded the PDF. If we destroy it before loadingTask.promise resolves, this produces an error that should not be treated as one.
  • Loading branch information
wojtekmaj committed May 31, 2023
1 parent bacc5bd commit 597bec1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ const Document = forwardRef(function Document(
pdfDispatch({ type: 'RESOLVE', value: nextPdf });
})
.catch((error) => {
if (loadingTask.destroyed) {
return;
}

pdfDispatch({ type: 'REJECT', error });
});

Expand Down

0 comments on commit 597bec1

Please sign in to comment.