mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Closes all promises/streams when handler is destroyed.
This commit is contained in:
parent
25806d17f4
commit
71b0e4e818
3 changed files with 41 additions and 15 deletions
|
@ -1632,8 +1632,33 @@ MessageHandler.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
destroy() {
|
||||
close(reason) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue