Do not await a long running Promise and return early to user.

I am using SvelteKit and deploying to Cloudflare Pages. In my SvelteKit Form Action (which is a Pages Function I think), what happens if I don't await an async operation and instead return early to the user. For instance, I have an endpoint which deletes images from Cloudflare Images, but I'd rather not make the user wait for that to happen, so I simply don't await the Promise.all that calls the Cloudflare API. It seems to be working great, but is this problematic? Note: this delete operation is fire and forget since I'll run a cronjob to cleanup. Example:
export const actions: Actions = {
deletePhotos: async (event) => {
// Delete from my database (critical)
await db.deletePhotos(...);

// Delete from Cloudflare (non-critical)
deletePhotosCloudflare(...);

return json({success: true});
}
}
export const actions: Actions = {
deletePhotos: async (event) => {
// Delete from my database (critical)
await db.deletePhotos(...);

// Delete from Cloudflare (non-critical)
deletePhotosCloudflare(...);

return json({success: true});
}
}
1 Reply
Want results from more Discord servers?
Add your server