23 / resumable.js

A JavaScript library for providing multiple simultaneous, stable, fault-tolerant and resumable/restartable uploads via the HTML5 File API.
MIT License
4.65k stars 612 forks source link

complete event is called multiple times if upload canceled #385

Open drazenp opened 7 years ago

drazenp commented 7 years ago

While uploading multiple files (e.g. 5MB and 100MB files) and canceling the upload of the second file the complete event is called multiple times. The number of complete triggers is equal to the parameter simultaneousUploads. Scenario:

The issue happens due to call of the method uploadNextChunk for each chunk with status 'uploading'.

If first file require only one chunk (size around 1MB) then 'complete' will be called only once. This could be another issue because it could happen that in this case the upload doesn't go in parallel.

The issue is reproducible with Node.js sample.

steffentchr commented 7 years ago

Thank you for a great write-up of the issue. Am curious to hear though about the specific negative consequences of multiple complete triggers?

drazenp commented 7 years ago

I'm relying on the complete event to show which files are uploaded. I cannot rely on fileSuccess since the uploading process can be canceled anytime. So I have to track successfully uploaded files and on the complete event show them.

This is not really stopper since with a flag it can be easily forced to work, but I guess upload should be completed only once :)

Is there a reason to call $.resumableObj.uploadNextChunk(); for each chunk while canceling upload?

calebhskim commented 7 years ago

I am also seeing this issue. In my setup I eventually pass my chunks to AWS' multipart upload API. When the complete event is fired I send a request to my server to send a request to AWS to stitch the chunks together. A premature/unexpected firing of the complete event causes AWS to stitch all the current chunks together for an existing upload. But since the request was premature not all the chunks are there meaning an incomplete file gets saved to S3. I can get around this by checking the progress of the file.

I agree with @drazenp and was wondering what the status on this was. Thanks!

TrueMoein commented 3 years ago

Same.