tus: log reason for QuotaExceededError

We no longer ask tus to save the upload URL since December, so there should no reason for it to be writing to localStorage.

Adding more logs to determine what is the actual cause -- localStorage being full, or not available. Neither should affect the upload but they are the only known causes for that error message, so try to narrow down the investigation path.
This commit is contained in:
infinite-persistence 2022-02-15 01:31:25 +08:00 committed by infinite-persistence
parent 7bbfd81762
commit 85ef16026d

View file

@ -83,6 +83,17 @@ export function makeResumableUploadRequest(
customErr = 'File is locked. Try resuming after waiting a few minutes';
}
let localStorageInfo;
if (errMsg.includes('QuotaExceededError')) {
try {
localStorageInfo = `${window.localStorage.length} items; ${
JSON.stringify(window.localStorage).length
} bytes`;
} catch (e) {
localStorageInfo = 'inaccessible';
}
}
window.store.dispatch(doUpdateUploadProgress({ guid, status: 'error' }));
analytics.sentryError('tus-upload', err);
@ -97,6 +108,7 @@ export function makeResumableUploadRequest(
...(uploader._retryAttempt ? { retryAttempt: uploader._retryAttempt } : {}),
...(uploader._offsetBeforeRetry ? { offsetBeforeRetry: uploader._offsetBeforeRetry } : {}),
...(customErr ? { original: errMsg } : {}),
...(localStorageInfo ? { localStorageInfo } : {}),
},
})
);