-
-
Notifications
You must be signed in to change notification settings - Fork 890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error handling - PDFJS worker termination while loading and unmounting component. #1062
Comments
And this appears to extend this: mozilla/pdf.js#11595 |
It might related to this issue: #729 (comment) |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days. |
This issue was closed because it has been stalled for 14 days with no activity. |
Bump? |
@wojtekmaj it seems that even if you use the onLoadError prop, pdf.js itself is still firing a error that propagates up. I can make a PR that suppresses these warnings using techniques discussed in the Mozilla thread. Is this something you think could get merged in (assuming good quality)? |
Sounds fair! Especially since I was to believe that we are already suppressing these errors :D Just please be aware that on main, currently, we have a completely new version so this fix would land in 7.x. |
@wojtekmaj that's a good point. Let me verify the version when I'm back in front of this and report findings. |
Got in the same issue. It appeared in unit tests (jest+RTL) after migrating from nodeJS v14 to nodeJS v16. |
HI @wojtekmaj , Still getting the same issue on version 7.3.3 |
This comment was marked as spam.
This comment was marked as spam.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
try to use the same version in whole project, I am using the different version pdf pdfjs seems trigger the issue(fisrt install pdfjs then install react-pdf but the react-pdf use old version of pdfjs). |
This is still a real issue :( There is no way that I have found to NOT log this error. Very annoying. |
Hi, just passing by and dropping a potential solution. We need to import the worker by this way (specified in docs): import { pdfjs } from 'react-pdf';
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.js',
import.meta.url,
).toString(); Worked for me, hope it helps. |
@mauudev Thanks for dropping the code. It's indeed worked for me too. 🍻 |
@mauudev I don't think this is really a fix, i have confirmed that when you set the workerSrc using either method you get the error. I'm still getting this exact issue on v9. Both of the following result in an AbortException when the component unmounts while loading. I can reliably reproduce this issue by throttling in dev tools. The following two methods of loading the workerSrc both result in errors pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs` pdfjs.GlobalWorkerOptions.workerSrc = `/static/js/pdf.worker-${pdfjs.version}.mjs` |
In case someone is looking for a workaround, mozilla/pdf.js#11595 (comment) |
@CyberAndrii in the context of react, should this be added to a useEffect unmount? |
It needs to be added here react-pdf/packages/react-pdf/src/Document.tsx Line 537 in 5f29bfb
But because it's not fixed in this package yet, we use patch-package to apply the fix. |
Before you start - checklist
Description
Sorry for the bump but is there any known solutions to this? This is referenced in this closed issue but seems as if the issue is stale and have a newer build then what is referenced here. It does not appear to be caught in the onLoadError.
#651
Steps to reproduce
Expected behavior
Graceful error handling or the ability to do a try catch, or an abort controller equivalent.
Actual behavior
React is not happy
Additional information
I happen to be using Gatsby, but this should persist even in vanilla React environments
Environment
The text was updated successfully, but these errors were encountered: