Skip to content

Commit 291ffd3

Browse files
committed
Fix handling of fetch errors
Testing: - delete the pdf file while the initial request is inflight - delete the pdf file after the initial request has finished Repeat for a small file and large file, exercising both one-off and chunked transports.
1 parent ada283c commit 291ffd3

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

src/core/chunked_stream.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class ChunkedStreamManager {
290290

291291
let chunks = [],
292292
loaded = 0;
293-
const promise = new Promise((resolve, reject) => {
293+
return new Promise((resolve, reject) => {
294294
const readChunk = chunk => {
295295
try {
296296
if (!chunk.done) {
@@ -311,14 +311,12 @@ class ChunkedStreamManager {
311311
}
312312
};
313313
rangeReader.read().then(readChunk, reject);
314-
});
315-
promise.then(data => {
314+
}).then(data => {
316315
if (this.aborted) {
317316
return; // Ignoring any data after abort.
318317
}
319318
this.onReceiveData({ chunk: data, begin });
320319
});
321-
// TODO check errors
322320
}
323321

324322
/**
@@ -369,7 +367,7 @@ class ChunkedStreamManager {
369367
groupedChunk.endChunk * this.chunkSize,
370368
this.length
371369
);
372-
this.sendRequest(begin, end);
370+
this.sendRequest(begin, end).catch(capability.reject);
373371
}
374372
}
375373

src/display/fetch_stream.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,7 @@ class PDFFetchStreamRangeReader {
247247
this._readCapability.resolve();
248248
this._reader = response.body.getReader();
249249
})
250-
.catch(reason => {
251-
if (reason?.name === "AbortError") {
252-
return;
253-
}
254-
throw reason;
255-
});
250+
.catch(this._readCapability.reject);
256251

257252
this.onProgress = null;
258253
}

0 commit comments

Comments
 (0)