1. How to handle promise rejections 2. How to cancel an upload that hasn't begun

I’m not sure if this is a bug or (more likely) issues with my code. If it is a bug, I’ll post this on Github issues.

I found this when writing an integration test on Cypress, when the test tried to delete a file. The delete button being ‘pressed’ before any part of the file had been uploaded led to an unhandled promise rejection (and failed the test).

const uppy = new Uppy({
	autoProceed: true,
});

uppy.use( AwsS3Multipart, {
	// ...other methods as per the docs. 
	abortMultipartUpload(_file, { key, uploadId }) {
		return new Promise((resolve, reject) => {
			const methodData = {
				bucket: 'bucket-name',
				uploadId,
				key,
			};
			// this is getting rejected by my API because uploadId is null
			abortAwsMultipartUpload.call(methodData, (err) => {
				if (err) {
					reject(err);
				} else {
					resolve();
				}
			});
		});
	},
});

// This is not catching/firing when the promise is rejected
uppy.on('error', (error) => {
	console.error('Uppy-Error ********************', error);
});

// This is also not catching/firing when the promise is rejected
uppy.on('upload-error', (file, error, response) => {
	console.log('error with file:', file.id);
	console.log('error message:', error);
	console.log('Error response', response);
});

When testing manually, everything works fine. After some debugging, I realise the integration test is failing because the ‘delete’ button is pressed before any part of the file has been uploaded, which leads to the abortMultipartUpload function being called without an uploadId (null).

This in turn is leading to an error: Uncaught (in promise) ClientError: Upload ID is required

Issues I am having:

  1. Why is the rejected promise coming up as uncaught and not being passed to the on(‘error’) event? How should I be catching rejected promises?
  2. What is the recommended way to handle an upload that is aborted before it is started (whereby uploadId is null)?

Thanks in advance and thanks for a great library!

Can you confirm what version are you using? We released recently a fix for bug that looks similar, I wonder if an update may solve your issue.

Thanks @aduh95 for the tip.

I’m currently on:
@uppy/aws-s3-multipart”: “^2.4.0”,
@uppy/core”: “^2.3.0”,

I have updated to:
@uppy/aws-s3-multipart”: “^2.4.1”,
@uppy/core”: “^2.3.2”,

The error (and unhandled promise rejection) still persists.