mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 17:55:37 +02:00
Ensure that ReadableStream
s are cancelled with actual Errors
There's a number of spots in the current code, and tests, where `cancel` methods are not called with appropriate arguments (leading to Promises not being rejected with Errors as intended). In some cases the cancel `reason` is implicitly set to `undefined`, and in others the cancel `reason` is just a plain String. To address this inconsistency, the patch changes things such that cancelling is done with `AbortException`s everywhere instead.
This commit is contained in:
parent
d909b86b28
commit
a3150166ec
8 changed files with 32 additions and 29 deletions
|
@ -16,10 +16,11 @@
|
|||
/* eslint no-var: error */
|
||||
|
||||
import {
|
||||
assert, createPromiseCapability, getVerbosityLevel, info, InvalidPDFException,
|
||||
isArrayBuffer, isSameOrigin, MissingPDFException, NativeImageDecoding,
|
||||
PasswordException, setVerbosityLevel, shadow, stringToBytes,
|
||||
UnexpectedResponseException, UnknownErrorException, unreachable, URL, warn
|
||||
AbortException, assert, createPromiseCapability, getVerbosityLevel, info,
|
||||
InvalidPDFException, isArrayBuffer, isSameOrigin, MissingPDFException,
|
||||
NativeImageDecoding, PasswordException, setVerbosityLevel, shadow,
|
||||
stringToBytes, UnexpectedResponseException, UnknownErrorException,
|
||||
unreachable, URL, warn
|
||||
} from '../shared/util';
|
||||
import {
|
||||
deprecated, DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer,
|
||||
|
@ -1768,7 +1769,8 @@ class WorkerTransport {
|
|||
Promise.all(waitOn).then(() => {
|
||||
this.fontLoader.clear();
|
||||
if (this._networkStream) {
|
||||
this._networkStream.cancelAllRequests();
|
||||
this._networkStream.cancelAllRequests(
|
||||
new AbortException('Worker was terminated.'));
|
||||
}
|
||||
|
||||
if (this.messageHandler) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue