Skip to content

Mail Worker Migration

This runbook covers migration from:

  • workers/cosmos/mail

to:

  • workers/bookmarks/mail

for auth verification/reset and other Bookmarks email delivery.

  • Estimated difficulty: medium (6/10)
  • Recommended timeline: 3-5 days including staging burn-in
  • Verification and reset emails send successfully.
  • No regression in auth flows that depend on email.
  • Fast rollback by restoring MAIL_SERVICE binding on auth worker.

Create Bookmarks-specific Cloudflare resources:

  • KV namespace for mail state
  • D1 database for mail metadata
  • queue + DLQ
  • secrets store entries (TURNSTILE_API_KEY, RESEND_API_KEY)

Update placeholders in:

  • workers/bookmarks/mail/wrangler.toml
  1. Deploy staging:
    • yarn workspace bookmarks-mail-worker deploy --env staging
  2. Verify staging endpoints and send-email path.
  3. Deploy production:
    • yarn workspace bookmarks-mail-worker deploy

Update auth worker service binding:

  • MAIL_SERVICE -> bookmarks-mail-worker (prod)
  • MAIL_SERVICE -> bookmarks-mail-worker-staging (staging)

Then deploy auth worker.

Run these checks:

  1. Register user -> verification email is sent.
  2. Verify email link resolves correctly.
  3. Password reset request -> email is sent.
  4. Password reset confirm succeeds.
  5. Logs show successful MAIL_SERVICE calls with no elevated 5xx rate.

If regressions occur:

  1. Re-point auth worker MAIL_SERVICE back to cosmos-mail-worker (or staging equivalent).
  2. Redeploy auth worker.
  3. Re-test verification/reset email flows.

Rollback target: under 15 minutes.

  • bookmarks-mail-worker deployed in staging
  • Staging verification/reset emails validated
  • bookmarks-mail-worker deployed in production
  • Auth worker MAIL_SERVICE switched
  • Production verification/reset emails validated
  • Monitoring clean for 48 hours