-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@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.
- Loading branch information
Showing
2 changed files
with
81 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters