gigafibre-fsm/services/targo-hub
louispaulb 6577bb79bc feat(campaigns/send): real SMTP error + auto-retry + one-click Renvoyer
The send worker used to write "SMTP send returned false (see hub logs)"
on every failure, forcing the operator to SSH into the box to find the
actual cause. Now we capture the real reason and surface it in the UI.

Three changes:

1. lib/email.js exposes getLastError() — a side-channel for the most
   recent nodemailer error message, cleared at the start of every
   sendEmail call. Legacy "if (await sendEmail(...))" callers stay on
   the false-return contract; only the campaign worker reads the
   side-channel for detailed error capture.

2. The worker now retries each recipient up to 3 times (initial +
   2 retries with 2s/5s backoff). Most "Unexpected socket close"-style
   transient Mailjet errors recover on the second attempt. We observed
   exactly this case for Myriam Bergevin in cmp-20260522-2d4605 — a
   single socket close interrupted 1 of 202 sends; auto-retry would
   have caught it. retry_count is now stored on the recipient.

3. POST /campaigns/:id/recipients/:row/retry resets a single failed
   row back to pending and re-fires the worker. Surfaced in the
   detail-page table as a small 🔁 button next to the error text on
   any row with status=failed. Useful when auto-retry exhausted its
   3 attempts on a one-off transient.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-22 13:29:25 -04:00
..
data refactor: reduce token count, DRY code, consolidate docs 2026-04-13 08:39:58 -04:00
lib feat(campaigns/send): real SMTP error + auto-retry + one-click Renvoyer 2026-05-22 13:29:25 -04:00
preview feat: flow editor, Gemini QR scanner with offline queue, dispatch planning v2 2026-04-22 10:44:17 -04:00
public refactor: major cleanup — remove dead dispatch app, commit all backend code, extract client composables 2026-04-08 17:38:38 -04:00
scripts feat(campaigns): convert existing HTML templates to Unlayer JSON designs 2026-05-22 06:22:47 -04:00
templates feat(campaigns/templates): visible wrapper-expiry date in the email 2026-05-22 10:47:58 -04:00
.env.example feat(hub+ops): user invite flow sends temp password via Mailjet + dev .env.example 2026-05-05 19:50:06 -04:00
docker-compose.yml fix(hub): templates volume mount must be RW for editor saves 2026-05-22 06:49:48 -04:00
package-lock.json feat(campaigns/editor): MJML mode — proper email-focused visual builder 2026-05-21 22:29:42 -04:00
package.json feat(campaigns/editor): MJML mode — proper email-focused visual builder 2026-05-21 22:29:42 -04:00
server.js feat(campaigns): gift redirect wrapper — own expiry + reusable links 2026-05-22 10:15:43 -04:00