question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:20
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
renaolivcommented, May 14, 2021

🤔 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 code

Screen Shot 2021-05-07 at 2 51 10 PM

I’m getting the same error, using the 5.3.0 version… does anyone have the solution?

2reactions
goodlanacommented, May 17, 2022

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 😄

import { Document, Page } from "react-pdf/dist/esm/entry.webpack";

from https://github.com/wojtekmaj/react-pdf/issues/729

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't perform a React state update on an unmounted ...
Warning: Can't perform a React state update on an unmounted component. Solution. You can declare let isMounted = true inside useEffect , which ......
Read more >
KendoReact Rich Text PDF Generator Overview - Telerik
Try our React PDF Generator Component by KendoReact that allows you to export a selection of or the entire content of a web...
Read more >
30-days-of-react-ebook-fullstackio.pdf
To see what this means, imagine we had a React component that renders an h1 HTML tag. ... Before the component is unmounted,...
Read more >
How To Code in React.js - DigitalOcean
But before you make any changes to the React JavaScript code, you will see how React renders to the page in the first...
Read more >
ReactJS i - Tutorialspoint
This tutorial starts with the architecture of React, how-to guide to setup projects, creating components, JSX and then walks through advanced concepts like ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found