Mail Worker Migration
Mail Worker Migration
Section titled “Mail Worker Migration”This runbook covers migration from:
workers/cosmos/mail
to:
workers/bookmarks/mail
for auth verification/reset and other Bookmarks email delivery.
Difficulty and timeline
Section titled “Difficulty and timeline”- Estimated difficulty: medium (6/10)
- Recommended timeline: 3-5 days including staging burn-in
Success criteria
Section titled “Success criteria”- Verification and reset emails send successfully.
- No regression in auth flows that depend on email.
- Fast rollback by restoring
MAIL_SERVICEbinding on auth worker.
Phase 1: Provision dedicated resources
Section titled “Phase 1: Provision dedicated resources”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
Phase 2: Deploy bookmarks-mail-worker
Section titled “Phase 2: Deploy bookmarks-mail-worker”- Deploy staging:
yarn workspace bookmarks-mail-worker deploy --env staging
- Verify staging endpoints and send-email path.
- Deploy production:
yarn workspace bookmarks-mail-worker deploy
Phase 3: Wire auth worker mail binding
Section titled “Phase 3: Wire auth worker mail binding”Update auth worker service binding:
MAIL_SERVICE->bookmarks-mail-worker(prod)MAIL_SERVICE->bookmarks-mail-worker-staging(staging)
Then deploy auth worker.
Phase 4: Validation
Section titled “Phase 4: Validation”Run these checks:
- Register user -> verification email is sent.
- Verify email link resolves correctly.
- Password reset request -> email is sent.
- Password reset confirm succeeds.
- Logs show successful
MAIL_SERVICEcalls with no elevated 5xx rate.
Rollback plan
Section titled “Rollback plan”If regressions occur:
- Re-point auth worker
MAIL_SERVICEback tocosmos-mail-worker(or staging equivalent). - Redeploy auth worker.
- Re-test verification/reset email flows.
Rollback target: under 15 minutes.
Checklist
Section titled “Checklist”-
bookmarks-mail-workerdeployed in staging - Staging verification/reset emails validated
-
bookmarks-mail-workerdeployed in production - Auth worker
MAIL_SERVICEswitched - Production verification/reset emails validated
- Monitoring clean for 48 hours