Skip to content

Conversation

@andriivitiv
Copy link
Contributor

Fixes #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:

throw new Error("Worker was terminated");

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, and onFailure is supposed to handle errors, not throw them.

Fixes mozilla#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:

https://github.com/mozilla/pdf.js/blob/6c746260a98766b8ece27018d2c48436cfcafa24/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](https://github.com/mozilla/pdf.js/blob/6c746260a98766b8ece27018d2c48436cfcafa24/src/core/worker.js#L371-L373), and `onFailure` is supposed to handle errors, not throw them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

loadingTask.destroy() throws worker exception

2 participants