-
Notifications
You must be signed in to change notification settings - Fork 10k
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
loadingTask.destroy() throws worker exception #11595
Comments
Are you sure about the "throws an exception" part, since what should be happening is that
I'm not seeing any exception, just a rejected Promise. The fact that you choose to ...
loadingTask.promise.then(function(pdf) {
...
}, function (reason) { <-- This attaches a rejection handler, hence that will stop any further error propagation.
// PDF loading error
console.error(reason);
}).catch((e) => console.log('It is not catching here'));
loadingTask.destroy(); The easiest way to handle this would be to simplify your code like so: ...
loadingTask.promise.then(function(pdf) {
...
}).catch((e) => console.log('Here's the error you're expecting.'));
loadingTask.destroy(); or possibly: ...
loadingTask.promise.then(function(pdf) {
...
}, function (reason) {
// PDF loading error
console.error(reason);
throw reason;
}).catch((e) => console.log('Here's the error you're expecting.''));
loadingTask.destroy(); All-in-all, there doesn't seem to be anything wrong with the PDF.js library here. |
I'm having the same issue, and no matter how I try to handle the promise (second If you search for the error in Google ( |
I got same , u should make sure not call destroy method,If you call this, It's mean worker will terminate, lifecycle will turn to unmount, if you use webpack load woker. The worker just load once ,It's the error reason |
There are two separate errors:
|
@doup is right. React example - loads pdf in a component on mount:
When the component is destroyed, we expect that it cancels the pdf loading and doesn't log anything to the console. It seems the exception happens here:
|
Perhaps the problem has a simple resolution - add a check if it was already destroyed:
:-) |
I am encounter the same error, any solution? |
This issue is that the "await this._transport?.destroy();" line in the destroy() function prevents the worker from getting destroyed immediately. The workaround is to destroy the worker manually:
You can add some checks in as well to ensure no errors occur:
|
I'm displaying a progress bar on document loading with a Cancel button to give a chance to the user to abort the download. If I understood correctly based on #6546 calling destroy() on the loading task is the correct way to do it. But that throws an exception in the worker what I even not able to catch anywhere.
Configuration:
Steps to reproduce the problem:
What is the expected behavior? (add screenshot)
Worker should stop without exception
What went wrong? (add screenshot)
Try https://jsfiddle.net/zmagyar/uLnqk1m5/1/#
Console says:
(index):76 Error: Worker was destroyed
at terminateEarly (api.js:1781)
at api.js:1827
at Worker.MessageHandler._onComObjOnMessage (message_handler.js:147)
The text was updated successfully, but these errors were encountered: