From a85f67c298753c69b17516f10a91be7f71e61346 Mon Sep 17 00:00:00 2001 From: Ben Senescu <44480372+bensenescu@users.noreply.github.com> Date: Fri, 3 Apr 2026 19:00:05 -0400 Subject: [PATCH] fix: remove better auth background tasks (#67) * Improve verify email page copy and design Remove redundant green success alert, update title to "Verify your email", rename button to "Resend email", and change footer link to "Back to sign in". * Fix verification emails not sending in production Remove the backgroundTasks/waitUntil handler so better-auth awaits email sending inline. Previously, errors thrown inside waitUntil promises were silently dropped by Cloudflare Workers, preventing emails from sending with no visible error logs. --- src/lib/auth.ts | 9 +-------- src/routes/verify-email.tsx | 14 ++++---------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 88f8cac..9373309 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -1,4 +1,4 @@ -import { env, waitUntil } from "cloudflare:workers"; +import { env } from "cloudflare:workers"; import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { tanstackStartCookies } from "better-auth/tanstack-start"; @@ -29,13 +29,6 @@ function createAuth() { baseURL: baseUrl, secret: getHostedSecret(), ...baseAuthConfig, - advanced: { - backgroundTasks: { - handler: (promise) => { - waitUntil(promise); - }, - }, - }, emailAndPassword: { ...baseAuthConfig.emailAndPassword, requireEmailVerification: true, diff --git a/src/routes/verify-email.tsx b/src/routes/verify-email.tsx index fa0814e..6d11e72 100644 --- a/src/routes/verify-email.tsx +++ b/src/routes/verify-email.tsx @@ -67,8 +67,8 @@ function getVerifyEmailPageCopy({ if (isWaiting && email) { return { - title: "Check your email", - helperText: `We sent a confirmation link to ${email}. Open it to confirm your email.`, + title: "Verify your email", + helperText: `Click the link we sent to ${email} to verify your email.`, }; } @@ -161,7 +161,7 @@ function VerifyEmailPage() { search={getSignInSearch(redirectTo)} className="text-base-content/50 hover:text-base-content transition-colors" > - Sign in + Back to sign in
} @@ -181,19 +181,13 @@ function VerifyEmailPage() { ) : isWaiting ? (