Ensure that ReadableStreams 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:
Jonas Jenwald 2019-08-01 16:31:32 +02:00
parent d909b86b28
commit a3150166ec
8 changed files with 32 additions and 29 deletions

View file

@ -14,6 +14,7 @@
*/
/* eslint no-var: error */
import { AbortException } from '../../src/shared/util';
import { PDFFetchStream } from '../../src/display/fetch_stream';
describe('fetch_stream', function() {
@ -72,7 +73,7 @@ describe('fetch_stream', function() {
isStreamingSupported = fullReader.isStreamingSupported;
isRangeSupported = fullReader.isRangeSupported;
// We shall be able to close full reader without any issue.
fullReader.cancel(new Error('Don\'t need full reader'));
fullReader.cancel(new AbortException('Don\'t need fullReader.'));
fullReaderCancelled = true;
});