Merge pull request #12144 from Snuffleupagus/uncaught-promise-AbortException
Prevent `Uncaught (in promise) AbortException` when running the unit-tests
This commit is contained in:
commit
0d20a2b7b4
@ -410,18 +410,24 @@ class ChunkedStreamManager {
|
|||||||
requestIds.push(requestId);
|
requestIds.push(requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chunksToRequest.length) {
|
if (chunksToRequest.length > 0) {
|
||||||
return capability.promise;
|
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);
|
return capability.promise.catch(reason => {
|
||||||
for (const groupedChunk of groupedChunksToRequest) {
|
if (this.aborted) {
|
||||||
const begin = groupedChunk.beginChunk * this.chunkSize;
|
return; // Ignoring any pending requests after abort.
|
||||||
const end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
|
}
|
||||||
this.sendRequest(begin, end);
|
throw reason;
|
||||||
}
|
});
|
||||||
|
|
||||||
return capability.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getStream() {
|
getStream() {
|
||||||
|
@ -2048,6 +2048,13 @@ class WorkerTransport {
|
|||||||
|
|
||||||
sink.onCancel = reason => {
|
sink.onCancel = reason => {
|
||||||
this._fullReader.cancel(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 => {
|
sink.onCancel = reason => {
|
||||||
rangeReader.cancel(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