-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retry on stalled upload #30776
Retry on stalled upload #30776
Conversation
retries = upload.data.retries || 0, | ||
retry = function () { | ||
var uid = OC.getCurrentUser().uid; | ||
upload.uploader.davClient.getFolderContents( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move this in a separate private function on the Uploader object if possible: getUploadedBytes()
. Too much nesting makes this difficult to read.
// only count full chunks | ||
&& file.size === fu.options.maxChunkSize | ||
) { | ||
data.uploadedBytes += file.size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a comment to explain why you need to calculate total size: is it to find out what chunk to resend ?
in general there is already information in the JS class about the last chunk so maybe you only need to PROPFIND said chunk to find out whether it was written at all ?
retries < fu.options.maxRetries) { | ||
retries += 1; | ||
upload.data.retries = retries; | ||
window.setTimeout(retry, retries * fu.options.retryTimeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice if retry
could also be a private method on the object instead of inline
|
I wonder why you didn't simply use the "fileuploadchunkfail" event, might be able to store the chunk id somewhere and reuse for retry instead of doing size computation. |
|
ok so from reading the code of jquery.fileupload.js it doesn't seem to have a way to resume upload directly after failure: https://github.com/owncloud/core/blob/v10.0.7/apps/files/js/jquery.fileupload.js#L802. This is likely the reason why you chose to go the route of restarting the upload from scratch, but specifying an initial "uploadedBytes" value to make the upload start at this offset. |
and apparently most of the code was copied from https://github.com/blueimp/jQuery-File-Upload/wiki/Chunked-file-uploads#automatic-resume and adjusted. I wonder why the jquery.fileupload devs didn't simply add a "retry" option and call |
Based on this information I will not try and find a better way since this is the recommended way from the jquery.fileupload wiki. Now to find a way to make this a bit more readable... |
Codecov Report
@@ Coverage Diff @@
## master #30776 +/- ##
============================================
- Coverage 62.31% 62.3% -0.01%
Complexity 18208 18208
============================================
Files 1142 1142
Lines 68190 68204 +14
Branches 1232 1232
============================================
+ Hits 42494 42496 +2
- Misses 25335 25347 +12
Partials 361 361
Continue to review full report at Codecov.
|
The reason why the progress bar disappears is because before retrying we first need to abort the upload: this removes the progress bar. But then there's the waiting delay of "retryTimeout" during which no progress bar is shown until an actual retry is attempted. I wonder whether we need this because we already have our own stall detection. |
Apart from that it seems to recover properly and it's able to finish the upload. The checksum is the same despite retries. At least with Chromium. Need to try with IE11 and Edge. We actually need to test not only with the stalled mode but also in case of actual chunk failure where the server returns an error code (like timeout). |
|
If yes then the logic above cannot work as the server would return the size of all chunks + the partial one. |
|
|
e103aa3
to
746adf7
Compare
Automated rebase with GitMate.io was successful! 🎉 |
does not work because these events only fire when progress is happening. no bytes sent => no progress event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed with @butonic the current solution is good enough to make it retry chunks 👍
stable10: #31005 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
fixes #30770
how to test
use this snippet to fake a bad connection:
now set a lower max chunk size and upload stall timeout:
you should see the uploads stall quite frequently. but now they get restarted an puck up where they left off.
introduces two new app config keys to control stalled uploads: