react-pdf: Throwing AbortException when unmounting react-pdf components before PDF is finished rendering
What 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:
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 22
- Comments: 25 (1 by maintainers)
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
v5.3.0 is now released. Glad to know it helped!
I did not find a solution for the problem, but luckily the crash is happening in the development mode only and not in the production 😃
Have the same issue. Very annoying if you have some quite big pdf-s. Unhandled exception basically crashes the app so it’s quite an issue when you want to implement some navigation 😃
🤔 Not seeing the same results here. On
react-pdf
5.2.0, if you navigate away from a PDF mid load on slow internet, it’ll still throw the following error. No special options, using vanilla sample codeI did not fix it. What I did, for a variety of reasons, was show the PDF one page at a time and I do not show the ‘close’ controls until the page is loaded.