Skip to content

Throwing AbortException when unmounting react-pdf components before PDF is finished rendering #651

@taylorbf

Description

@taylorbf

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions