stack/apps
Mantra 7957de4182
fix(email-queue): recover stuck sending without duplicate retry (#1356)
## Summary

Email outbox rows can get stuck in `SENDING` if a worker dies after
setting `startedSendingAt` but before finishing or unclaiming. This
change adds `recoverEmailsStuckInSending`, which runs each email queue
step and marks rows past the stuck timeout as **terminal server errors**
with delivery status unknown, **without** scheduling an automatic retry
(to avoid duplicate sends if the provider already accepted the message).

## Changes

- **`recoverEmailsStuckInSending`**: updates stuck rows with
`finishedSendingAt`, `canHaveDeliveryInfo: false`, and server error
fields; emits Sentry via `captureError` when any rows are recovered.
- **Tests**: `email-queue-step.test.tsx` covers recovery of old
`startedSendingAt`, no-op for recent sends, and idempotency (second pass
does not re-queue).

## Test plan

- [ ] `pnpm` / vitest for
`apps/backend/src/lib/email-queue-step.test.tsx` (requires dev DB like
other integration tests in this package)

Made with [Cursor](https://cursor.com)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Email reliability: messages that remained stuck in sending are now
automatically marked as terminal failures, assigned standardized error
details, cleared from retry scheduling, prevented from receiving
delivery info, and recovery emits an alert only when actual work occurs.
Recovery is safe to run repeatedly (idempotent).

* **Tests**
* Added integration tests validating recovery behavior, proper field
updates, and idempotency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-24 11:00:46 -07:00
..
backend fix(email-queue): recover stuck sending without duplicate retry (#1356) 2026-04-24 11:00:46 -07:00
dashboard fix(dashboard): Restricted row styling + Replays empty state (#1366) 2026-04-22 17:42:39 -07:00
dev-launchpad chore: update package versions 2026-04-20 19:06:56 -07:00
e2e fix connected accounts tokens (#1358) 2026-04-20 19:33:47 -07:00
hosted-components chore: update package versions 2026-04-20 19:06:56 -07:00
internal-tool fix(internal-tool): continue dev startup when spacetime publish fails (#1371) 2026-04-22 22:35:27 +00:00
mock-oauth-server chore: update package versions 2026-04-20 19:06:56 -07:00
oauth-mock-server In-source unit tests (#429) 2025-02-14 11:47:52 -08:00