Skip to content

Fluctuating resumableTotalChunks parameter #567

@dannydjrs

Description

@dannydjrs

During a large upload, the sent resumableTotalChunks parameter can sometimes not be the actual value and can differ between chunks sent.

Dev Notes

I have looked into the possible reason and have narrowed it down to the following:

  • ResumableFile.bootstrap is called to initialise all the ResumableChunks and store them in the ResumableFile.chunks array.
  • Once bootstrap is completed the upload of the ResumableFile is allowed to begin
  • However, on completion, the bootstrap function has not added any chunks to the chunks array
  • This is due to the window.setTimeout surrounding the actual push of the new chunk (making it run asynchronously), forcing the bootstrap function to complete before all the setTimeout contents have completed.

image

  • Therefore, this is allowing upload to be started whilst the ResumableChunks are still being added to the chunks array
  • As the resumableTotalChunks parameter is determined from the length of the chunks array, this is what it causing the fluctuation.

Example

Example request parameters sent:

  • note the change in resumableTotalChunks
  • also how it is not the actual value of 984
resumableChunkNumber=2&resumableChunkSize=1048576&resumableCurrentChunkSize=1048576&resumableTotalSize=1031744025&resumableType=&resumableIdentifier=###&resumableFilename=###&resumableRelativePath=###&resumableTotalChunks=394

resumableChunkNumber=3&resumableChunkSize=1048576&resumableCurrentChunkSize=1048576&resumableTotalSize=1031744025&resumableType=&resumableIdentifier=###&resumableFilename=###&resumableRelativePath=###&resumableTotalChunks=400

Possible fixes

  1. Remove the setTimeout around the push to the array
  2. Determine the totalChunks using the fileSize and chunkSize rather than length of chunks array

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions