Skip to content

fix: staging email not delivered#274

Merged
amandazhuyilan merged 1 commit into
mainfrom
fix-email-job
May 28, 2026
Merged

fix: staging email not delivered#274
amandazhuyilan merged 1 commit into
mainfrom
fix-email-job

Conversation

@amandazhuyilan

Copy link
Copy Markdown
Contributor

Description

Fix: Scheduler crashes after sending emails (staging emails not delivered)

Problem

The email scheduler was silently dying after attempting to send any email. This caused all subsequent emails to never be processed.

Changes

  • scheduled_tasks/scheduler.py— Added a dedicated "email", MemoryJobStore alongside the existing SQLAlchemy default store
  • scheduled_tasks/tasks.py — One-shot email delivery jobs now use jobstore="email" (in-memory) instead of the SQLAlchemy store

Why this works

  • One-shot email delivery jobs don't need DB persistence — the EmailNotification table already tracks all email state (PENDINGSENDINGSENT/FAILED).
  • Using an in-memory store for these ephemeral jobs removes the SQLAlchemy race condition entirely.
  • Recurring jobs (process_email_queue, cleanup_email_otps) are unaffected and continue using the PostgreSQL job store.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have added unit / integration tests that prove my fix is effective or that my feature works
  • I have run all tests locally and they pass
  • I have updated the documentation (if applicable)
  • For any new secrets, I have updated the shared spreadsheet and the GitHub Secrets.

@marius-mather marius-mather left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, looks like a nice way to do this

@amandazhuyilan amandazhuyilan merged commit edceec9 into main May 28, 2026
5 checks passed
@amandazhuyilan amandazhuyilan deleted the fix-email-job branch May 28, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants