Skip to content

Commit

Permalink
@uppy/aws-s3-multipart: ignore exception inside abortMultipartUpload (
Browse files Browse the repository at this point in the history
#3950)

The docs say "Cancellation cannot fail in Uppy, so the result of this
function is ignored". So let's ignore it indeed.
  • Loading branch information
aduh95 committed Aug 4, 2022
1 parent 3fed45a commit 96252e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 4 additions & 6 deletions packages/@uppy/aws-s3-multipart/src/MultipartUploader.js
Expand Up @@ -425,12 +425,10 @@ class MultipartUploader {
#abortUpload () {
this.abortController.abort()

this.createdPromise.then(() => {
this.options.abortMultipartUpload({
key: this.key,
uploadId: this.uploadId,
})
}, () => {
this.createdPromise.then(() => this.options.abortMultipartUpload({
key: this.key,
uploadId: this.uploadId,
})).catch(() => {
// if the creation failed we do not need to abort
})
}
Expand Down
9 changes: 5 additions & 4 deletions packages/@uppy/aws-s3-multipart/src/index.test.js
Expand Up @@ -213,11 +213,12 @@ describe('AwsS3Multipart', () => {
.use(AwsS3Multipart, {
createMultipartUpload,
completeMultipartUpload: jest.fn(async () => ({ location: 'test' })),
abortMultipartUpload: jest.fn(),
// eslint-disable-next-line no-throw-literal
abortMultipartUpload: jest.fn(() => { throw 'should ignore' }),
prepareUploadParts:
prepareUploadParts
// eslint-disable-next-line prefer-promise-reject-errors
.mockImplementationOnce(() => Promise.reject({ source: { status: 500 } })),
prepareUploadParts
// eslint-disable-next-line prefer-promise-reject-errors
.mockImplementationOnce(() => Promise.reject({ source: { status: 500 } })),
})
const awsS3Multipart = core.getPlugin('AwsS3Multipart')
const fileSize = 5 * MB + 1 * MB
Expand Down

0 comments on commit 96252e5

Please sign in to comment.