Throwing AbortException when unmounting react-pdf components before PDF is finished rendering
See original GitHub issueWhat are you trying to achieve? Please describe.
I’d like to be able to unmount my PDF viewer component before the PDF is finished rendering, without having an unhandled promise exception.
Describe solutions you’ve tried
I have tried using the available onRenderError, onLoadError, etc props. I’ve also tried wrapping the component in an ErrorBoundary, however it does not catch this error.
Additional information
This is an unhandled promise exception from within PDF.js. I wonder if this exception could be handled within your library or if a prop could be exposed to handle this error. I imagine others have come across this error and I wonder how others have solved this.
When unmounting the <Document>
and <Page>
before it is finished rendering:
Uncaught (in promise) pdf.js:1153
AbortException: {
message: "Worker was terminated."
name: "AbortException"
}
Using this worker: 'react-pdf/dist/esm/entry.webpack.js'
Environment
- Browser Chrome 85:
- React-PDF version 5.0.0:
- React version 16.10.2:
- Webpack version 4.41.0:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:20
- Comments:20 (1 by maintainers)
Top GitHub Comments
I’m getting the same error, using the 5.3.0 version… does anyone have the solution?
If there is anyone still suffered from this issue, just change the import-alias. I’m using v5.7.3, and it doesn’t seem like they solved this issue… below code saved my life. hope it helps you 😄
from https://github.com/wojtekmaj/react-pdf/issues/729