Skip to content

Commit

Permalink
Merge pull request #28 from biigle/upload-err-handling
Browse files Browse the repository at this point in the history
Change re-upload behaviour of storage requests
  • Loading branch information
mzur committed Apr 10, 2024
2 parents 80f23dd + dfccb6e commit a28fb8e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/resources/assets/js/createContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {LoaderMixin, handleErrorResponse, FileBrowserComponent} from './import';
import {sizeForHumans} from './utils';
// Number of times a file upload is retried.
const RETRY_UPLOAD = 2;
const RETRY_UPLOAD = 3;
export default {
mixins: [LoaderMixin],
Expand Down Expand Up @@ -428,9 +428,12 @@ export default {
// Try uploading again on server error until number of retries is
// reached.
if (e.status >= 500 && retryCount < RETRY_UPLOAD) {
return this.uploadBlob(blob, prefix, chunkIndex, totalChunks, retryCount + 1);
// Add delay to prevent failing uploads due to e.g. BIIGLE instance updates or
// short moments of unavailability.
return new Vue.Promise((resolve) => {
setTimeout(() => resolve(this.uploadBlob(blob, prefix, chunkIndex, totalChunks, retryCount + 1)), 5000);
});
}
throw e;
});
},
Expand Down

0 comments on commit a28fb8e

Please sign in to comment.