diff --git a/src/core/worker.js b/src/core/worker.js index 40069215c..a905efe27 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -14,11 +14,10 @@ */ import { - AbortException, arrayByteLength, arraysToBytes, assert, - createPromiseCapability, info, InvalidPDFException, isNodeJS, MessageHandler, - MissingPDFException, PasswordException, setVerbosityLevel, - UnexpectedResponseException, UnknownErrorException, UNSUPPORTED_FEATURES, - warn, XRefParseException + arrayByteLength, arraysToBytes, assert, createPromiseCapability, info, + InvalidPDFException, isNodeJS, MessageHandler, MissingPDFException, + PasswordException, setVerbosityLevel, UnexpectedResponseException, + UnknownErrorException, UNSUPPORTED_FEATURES, warn, XRefParseException } from '../shared/util'; import { LocalPdfManager, NetworkPdfManager } from './pdf_manager'; import { Ref } from './primitives'; @@ -842,7 +841,7 @@ var WorkerMessageHandler = { return Promise.all(waitOn).then(function () { // Notice that even if we destroying handler, resolved response promise // must be sent back. - handler.close(new AbortException('Worker was terminated')); + handler.destroy(); handler = null; }); }); diff --git a/src/display/api.js b/src/display/api.js index 74e9876b0..63bb9fc85 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -15,11 +15,11 @@ /* globals requirejs, __non_webpack_require__ */ import { - AbortException, assert, createPromiseCapability, deprecated, - getVerbosityLevel, info, InvalidPDFException, isArrayBuffer, isSameOrigin, - loadJpegStream, MessageHandler, MissingPDFException, NativeImageDecoding, - PageViewport, PasswordException, StatTimer, stringToBytes, - UnexpectedResponseException, UnknownErrorException, Util, warn + assert, createPromiseCapability, deprecated, getVerbosityLevel, info, + InvalidPDFException, isArrayBuffer, isSameOrigin, loadJpegStream, + MessageHandler, MissingPDFException, NativeImageDecoding, PageViewport, + PasswordException, StatTimer, stringToBytes, UnexpectedResponseException, + UnknownErrorException, Util, warn } from '../shared/util'; import { DOMCanvasFactory, DOMCMapReaderFactory, getDefaultSetting, @@ -1382,7 +1382,7 @@ var PDFWorker = (function PDFWorkerClosure() { var messageHandler = new MessageHandler('main', 'worker', worker); var terminateEarly = () => { worker.removeEventListener('error', onWorkerError); - messageHandler.close(new Error('Worker was terminated')); + messageHandler.destroy(); worker.terminate(); if (this.destroyed) { this._readyCapability.reject(new Error('Worker was destroyed')); @@ -1424,7 +1424,7 @@ var PDFWorker = (function PDFWorkerClosure() { }); } else { this._setupFakeWorker(); - messageHandler.close(new Error('Worker was terminated')); + messageHandler.destroy(); worker.terminate(); } }); @@ -1527,7 +1527,7 @@ var PDFWorker = (function PDFWorkerClosure() { pdfWorkerPorts.delete(this._port); this._port = null; if (this._messageHandler) { - this._messageHandler.close(new AbortException('Worker was destroyed')); + this._messageHandler.destroy(); this._messageHandler = null; } }, @@ -1607,7 +1607,7 @@ var WorkerTransport = (function WorkerTransportClosure() { } if (this.messageHandler) { - this.messageHandler.close(new AbortException('Worker was destroyed')); + this.messageHandler.destroy(); this.messageHandler = null; } this.destroyCapability.resolve(); diff --git a/src/shared/util.js b/src/shared/util.js index ce9a50453..aa1b2e07b 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -1628,33 +1628,8 @@ MessageHandler.prototype = { } }, - close(reason) { + destroy() { this.comObj.removeEventListener('message', this._onComObjOnMessage); - - // Reject all promises and streams. - for (let i in this.callbacksCapabilities) { - const callbackCapability = this.callbacksCapabilities[i]; - callbackCapability.reject(reason); - } - for (let i in this.streamSinks) { - const sink = this.streamSinks[i]; - sink.sinkCapability.reject(reason); - } - for (let i in this.streamControllers) { - const controller = this.streamControllers[i]; - if (!controller.isClosed) { - controller.controller.error(reason); - } - if (controller.startCall) { - controller.startCall.reject(reason); - } - if (controller.pullCall) { - controller.pullCall.reject(reason); - } - if (controller.cancelCall) { - controller.cancelCall.reject(reason); - } - } }, };