From 75d5ed73dc7b7ea6c4ff598297d69815221b09c1 Mon Sep 17 00:00:00 2001 From: vato007 Date: Thu, 13 Feb 2025 22:45:02 +1030 Subject: [PATCH] Immediately return in pages function when sending email through contact form --- functions/contact.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/functions/contact.ts b/functions/contact.ts index 6d8114b..a870e83 100644 --- a/functions/contact.ts +++ b/functions/contact.ts @@ -29,13 +29,15 @@ export const onRequest: PagesFunction = (context) => { // Must have some kind of identifiable information for me to actually care about them. if ((fullName || email) && message) { try { - await context.env.SERVICE.sendEmail({ - fullName, - organisation, - email, - mobile, - message, - }); + context.waitUntil( + context.env.SERVICE.sendEmail({ + fullName, + organisation, + email, + mobile, + message, + }) + ); } catch (e) { return new Response(e); }