Prevent Uncaught (in promise) AbortException
when running the unit-tests
These errors can/will occur if data is still loading when the document is destroyed, which is the case in the API unit-tests that load the `tracemonkey.pdf` file. While this patch prevents these kind of problems, and thus allows us to update Jasmine again, I cannot help but thinking that it's slightly "hacky". Basically, we'll simply catch and ignore (some) rejected promises once the document is destroyed and/or its data loading is aborted. However, I don't *think* that these changes should cause issues in general, since we don't really care about errors once document destruction has started (note e.g. the fair number of `catch` handlers ignoring `AbortException`s already).
This commit is contained in:
parent
c5663f2f6b
commit
6d192f987e
@ -410,18 +410,24 @@ class ChunkedStreamManager {
|
||||
requestIds.push(requestId);
|
||||
}
|
||||
|
||||
if (!chunksToRequest.length) {
|
||||
return capability.promise;
|
||||
if (chunksToRequest.length > 0) {
|
||||
const groupedChunksToRequest = this.groupChunks(chunksToRequest);
|
||||
for (const groupedChunk of groupedChunksToRequest) {
|
||||
const begin = groupedChunk.beginChunk * this.chunkSize;
|
||||
const end = Math.min(
|
||||
groupedChunk.endChunk * this.chunkSize,
|
||||
this.length
|
||||
);
|
||||
this.sendRequest(begin, end);
|
||||
}
|
||||
}
|
||||
|
||||
const groupedChunksToRequest = this.groupChunks(chunksToRequest);
|
||||
for (const groupedChunk of groupedChunksToRequest) {
|
||||
const begin = groupedChunk.beginChunk * this.chunkSize;
|
||||
const end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
|
||||
this.sendRequest(begin, end);
|
||||
}
|
||||
|
||||
return capability.promise;
|
||||
return capability.promise.catch(reason => {
|
||||
if (this.aborted) {
|
||||
return; // Ignoring any pending requests after abort.
|
||||
}
|
||||
throw reason;
|
||||
});
|
||||
}
|
||||
|
||||
getStream() {
|
||||
|
@ -2048,6 +2048,13 @@ class WorkerTransport {
|
||||
|
||||
sink.onCancel = reason => {
|
||||
this._fullReader.cancel(reason);
|
||||
|
||||
sink.ready.catch(readyReason => {
|
||||
if (this.destroyed) {
|
||||
return; // Ignore any pending requests if the worker was terminated.
|
||||
}
|
||||
throw readyReason;
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
@ -2127,6 +2134,13 @@ class WorkerTransport {
|
||||
|
||||
sink.onCancel = reason => {
|
||||
rangeReader.cancel(reason);
|
||||
|
||||
sink.ready.catch(readyReason => {
|
||||
if (this.destroyed) {
|
||||
return; // Ignore any pending requests if the worker was terminated.
|
||||
}
|
||||
throw readyReason;
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user