Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleteProject handler doesn't wait for S3 deletion to complete #3023

Closed
lindapaiste opened this issue Feb 14, 2024 · 5 comments · Fixed by #3152
Closed

deleteProject handler doesn't wait for S3 deletion to complete #3023

lindapaiste opened this issue Feb 14, 2024 · 5 comments · Fixed by #3152

Comments

@lindapaiste
Copy link
Collaborator

Increasing Access

It seems like we could end up with files left behind on S3, which use up resources.

Feature enhancement details

The deleteProject handler fires off an asynchronous function deleteObjectsFromS3 (via deleteFilesFromS3) but it does not wait for the S3 deletion to continue before sending an API response.

I'm not sure what actually happens here -- do those files continue to get deleted in the background or not? I'm concerned that we could wind up with "leftover" files on S3 that are no longer linked to any project.

There is no waiting here:

deleteFilesFromS3(project.files);
project.remove((removeProjectError) => {
if (removeProjectError) {
sendProjectNotFound();
return;
}
res.status(200).end();
});
}

I noticed this thanks to a warning in my IDE
image

@rahulrana701
Copy link
Contributor

rahulrana701 commented Feb 15, 2024

I think for that we need to ensure that the s3 deletion process completes before sending the api response we can achieve it by modifying the delete project function to wait for the asynchronous deleteFilesFroms3 function to finish executing , for that we can use promises or asynchronous/await @lindapaiste what are your views on this , if this approach is correct , I would like to work on this issue

@ash97531
Copy link

Can anyone please check where I am making a mistake in the AWS setup?
I have described my error in this thread: #2984

@rahulrana701
Copy link
Contributor

rahulrana701 commented Feb 18, 2024

@lindapaiste what is your say on this ??

@letscodedanish
Copy link
Contributor

letscodedanish commented Feb 23, 2024

##Problem
The warning "Promise returned from deleteObjectsFromS3 is ignored" indicates that the deleteObjectsFromS3 function is returning a promise, but its resolution is not being handled properly. This warning suggests that there might be potential issues with the asynchronous operation not being properly managed, which could lead to unexpected behavior or resource leaks.

##Action to fix
To address this warning, you need to ensure that you handle the promise returned by deleteObjectsFromS3 appropriately. This typically involves using either async/await or .then() to handle the promise resolution and execution flow.

To fix the warning "Promise returned from deleteObjectsFromS3 is ignored," you can take the following actions:

1.Handle the Promise: Ensure that the Promise returned by deleteObjectsFromS3 is properly handled to avoid potential issues with asynchronous operations. We can use async/await or .then() to handle the Promise resolution and execution flow.
2.Using async/await

@lindapaiste I would love to fix this issue, please assign this to me.

@PiyushChandra17
Copy link
Contributor

@lindapaiste @raclim I think on the latest develop, we are already handling the promises returned from deleteFilesFromS3 using async/await. IMO async/await is much cleaner and modern way to handle promises instead of .then() and .catch(). I have just added more robust way to handle error in the catch block here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants