Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/api/cron/emails/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export async function GET(req: Request) {

const result = await runCronEmails();
if (!result.success) {
return NextResponse.json({ success: false, error: "Database unavailable" }, { status: 500 });
// Report the cause the workflow actually returned. Hardcoding one of the
// two made an email-configuration failure read as a database failure, and
// the operator chased Postgres while the sender address was the problem.
return NextResponse.json({ success: false, error: result.error }, { status: 500 });
}
return NextResponse.json(result);
}
10 changes: 9 additions & 1 deletion lib/workflows/cron-emails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ export async function runCronEmails(now: Date = new Date()): Promise<CronEmailsR
// No provider → leave every row pending (retried next run once configured)
// instead of "sending" into the void and marking the queue sent.
if (!isEmailConfigured()) {
console.error("[cron/emails] RESEND_API_KEY not configured — queue left pending");
// Name the real reason. isEmailConfigured() is false for TWO reasons and
// this line only ever announced one of them, so a sandbox sender — the
// case the guard was written for — reported a missing key that was
// present and correctly shaped.
console.error(
process.env.RESEND_API_KEY
? "[cron/emails] sender is a sandbox address that reaches nobody — queue left pending"
: "[cron/emails] RESEND_API_KEY not configured — queue left pending"
);
return { success: false, error: "Email provider not configured" };
}

Expand Down
Loading