Merge pull request #13937 from overleaf/jpa-fix-error-handling

Fix handling of fetch errors
This commit is contained in:
Jonas Jenwald 2021-08-30 15:50:03 +02:00 committed by GitHub
commit cf0ccc4bab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 11 deletions

View File

@ -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) {
@ -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
}
/**
@ -369,7 +367,7 @@ class ChunkedStreamManager {
groupedChunk.endChunk * this.chunkSize,
this.length
);
this.sendRequest(begin, end);
this.sendRequest(begin, end).catch(capability.reject);
}
}

View File

@ -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;
}