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:
- 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? - 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!