mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-25 09:35:48 +02:00
Fix Worker was terminated error when loading is cancelled
Fixes https://github.com/mozilla/pdf.js/issues/11595, where cancelling loading with `loadingTask.destroy()` before it finishes throws a `Worker was terminated` error that CANNOT be caught. When worker is terminated, an error is thrown here:6c746260a9/src/core/worker.js (L374)Then `onFailure` runs, in which we throw again via `ensureNotTerminated()`. However, this second error is never caught (and cannot be), resulting in console spam. There is no need to throw any additional errors since the termination is already reported [here](6c746260a9/src/core/worker.js (L371-L373)), and `onFailure` is supposed to handle errors, not throw them.
This commit is contained in:
parent
6c746260a9
commit
9677798ba0
@ -319,7 +319,9 @@ class WorkerMessageHandler {
|
||||
}
|
||||
|
||||
function onFailure(ex) {
|
||||
ensureNotTerminated();
|
||||
if (terminated) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ex instanceof PasswordException) {
|
||||
const task = new WorkerTask(`PasswordException: response ${ex.code}`);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user