Skip to content

Fix handling of fetch errors #13937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/core/chunked_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class ChunkedStreamManager {

let chunks = [],
loaded = 0;
const promise = new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
const readChunk = chunk => {
try {
if (!chunk.done) {
Expand All @@ -311,14 +311,12 @@ class ChunkedStreamManager {
}
};
rangeReader.read().then(readChunk, reject);
});
promise.then(data => {
}).then(data => {
if (this.aborted) {
return; // Ignoring any data after abort.
}
this.onReceiveData({ chunk: data, begin });
});
// TODO check errors
}

/**
Expand Down Expand Up @@ -369,7 +367,7 @@ class ChunkedStreamManager {
groupedChunk.endChunk * this.chunkSize,
this.length
);
this.sendRequest(begin, end);
this.sendRequest(begin, end).catch(capability.reject);
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/display/fetch_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,7 @@ class PDFFetchStreamRangeReader {
this._readCapability.resolve();
this._reader = response.body.getReader();
})
.catch(reason => {
if (reason?.name === "AbortError") {
return;
}
throw reason;
});
.catch(this._readCapability.reject);

this.onProgress = null;
}
Expand Down