Notify: Re-enable delay but only for initial connection problem

We want to avoid the double `notify`, and also to confirm whether the SDK is timing out.
This commit is contained in:
infinite-persistence 2021-11-12 11:09:25 +08:00 committed by infinite-persistence
parent 9bfa1a3577
commit 861aaf4cde

View file

@ -56,7 +56,7 @@ export function makeResumableUploadRequest(
window.store.dispatch(doUpdateUploadProgress({ params, progress: percentage })); window.store.dispatch(doUpdateUploadProgress({ params, progress: percentage }));
}, },
onSuccess: () => { onSuccess: () => {
let retries = 0; let retries = 1;
function makeNotifyRequest() { function makeNotifyRequest() {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
@ -70,9 +70,9 @@ export function makeResumableUploadRequest(
resolve(xhr); resolve(xhr);
}; };
xhr.onerror = () => { xhr.onerror = () => {
if (--retries > 0) { if (retries > 0 && xhr.status === 0) {
// Auto-retry after 10s delay. --retries;
setTimeout(() => makeNotifyRequest(), 10000); setTimeout(() => makeNotifyRequest(), 10000); // Auto-retry after 10s delay.
} else { } else {
window.store.dispatch(doUpdateUploadProgress({ params, status: 'error' })); window.store.dispatch(doUpdateUploadProgress({ params, status: 'error' }));
reject(new Error(`There was a problem in the processing. Please retry. (${xhr.status})`)); reject(new Error(`There was a problem in the processing. Please retry. (${xhr.status})`));