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.
This commit is contained in:
parent
ada283cc35
commit
291ffd3059
@ -290,7 +290,7 @@ class ChunkedStreamManager {
|
|||||||
|
|
||||||
let chunks = [],
|
let chunks = [],
|
||||||
loaded = 0;
|
loaded = 0;
|
||||||
const promise = new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const readChunk = chunk => {
|
const readChunk = chunk => {
|
||||||
try {
|
try {
|
||||||
if (!chunk.done) {
|
if (!chunk.done) {
|
||||||
@ -311,14 +311,12 @@ class ChunkedStreamManager {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
rangeReader.read().then(readChunk, reject);
|
rangeReader.read().then(readChunk, reject);
|
||||||
});
|
}).then(data => {
|
||||||
promise.then(data => {
|
|
||||||
if (this.aborted) {
|
if (this.aborted) {
|
||||||
return; // Ignoring any data after abort.
|
return; // Ignoring any data after abort.
|
||||||
}
|
}
|
||||||
this.onReceiveData({ chunk: data, begin });
|
this.onReceiveData({ chunk: data, begin });
|
||||||
});
|
});
|
||||||
// TODO check errors
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,7 +367,7 @@ class ChunkedStreamManager {
|
|||||||
groupedChunk.endChunk * this.chunkSize,
|
groupedChunk.endChunk * this.chunkSize,
|
||||||
this.length
|
this.length
|
||||||
);
|
);
|
||||||
this.sendRequest(begin, end);
|
this.sendRequest(begin, end).catch(capability.reject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,12 +247,7 @@ class PDFFetchStreamRangeReader {
|
|||||||
this._readCapability.resolve();
|
this._readCapability.resolve();
|
||||||
this._reader = response.body.getReader();
|
this._reader = response.body.getReader();
|
||||||
})
|
})
|
||||||
.catch(reason => {
|
.catch(this._readCapability.reject);
|
||||||
if (reason?.name === "AbortError") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw reason;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.onProgress = null;
|
this.onProgress = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user