Skip to content
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

@uppy/aws-s3-multipart: Fix race condition in #uploadParts #3955

Merged
merged 2 commits into from Aug 8, 2022

Commits on Aug 4, 2022

  1. @uppy/aws-s3-multipart: Fix race condition in #uploadParts

    The `#uploadParts` function calls itself after any part is uploaded. It also
    determines which new chunks to upload based on their `state.busy` value. This
    introduced a race condition, as `state.busy` was being set to false in the XHR
    event handlers. So if one part were to complete while another part had finished
    the XHR request, but not yet completed, then an upload for that second part
    would be started again, despite the fact that the previous upload was still in
    progress. Multiple uploads for the same part at the same time cause numerous
    issues, and should never happen.
    
    This is especially noticeable when an XHR request fails. `#uploadPart` is
    wrapped in `#retryable`, so the part will be retried, however, for the entire
    `retryDelay`, the chunk's `state.busy` value would be false, meaning that if
    any other part completed, this part would be uploaded again, despite the fact
    that the upload is already ongoing.
    
    To fix this, this commit moves setting `state.busy` to the `before` and `after`
    functions of the `#retryable` call, so a part will remain `busy` for the entire
    time it is being uploaded/retried.
    mogzol committed Aug 4, 2022
    Copy the full SHA
    3b878af View commit details
    Browse the repository at this point in the history

Commits on Aug 5, 2022

  1. Copy the full SHA
    928a1ed View commit details
    Browse the repository at this point in the history