uppy/packages
Morgan Zolob 24b584ff74
@uppy/aws-s3-multipart: Fix race condition in #uploadParts (#3955)
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.
2022-08-08 12:15:02 +02:00
..
@uppy @uppy/aws-s3-multipart: Fix race condition in #uploadParts (#3955) 2022-08-08 12:15:02 +02:00
uppy Release: uppy@3.0.0-beta.4 (#3943) 2022-08-03 10:06:32 +00:00