mailship/test
Agent 737f949f9b fix digest job race: delete sent events by ID, not timestamp
Bug: runJob computed since = sub.last_digest_at, fetched events with
received_at > since, sent the digest (slow), then deleted ALL events
with received_at > since. Any /notify event that arrived between the
fetch and the delete was also received_at > since, so it was deleted
without ever being sent in a digest.

Two changes:

1. Delete by exact event IDs (src/database.ts, src/worker/email.ts):
   Added deleteEventsByIds(subscriptionId, eventIds) which deletes
   only the events that were actually fetched + sent. The old
   timestamp-based delete is retained but no longer called from runJob.

2. Re-fetch subscription on each cron tick (src/worker/email.ts):
   createJob's closure captured the original sub, so sub.last_digest_at
   stayed stale in memory. Every subsequent tick recomputed since from
   the old value, re-fetching and re-sending duplicate events. Now each
   tick re-fetches the subscription from the DB via getSubscriptionById
   before calling runJob.

Fixes bead mailship-091
2026-09-14 13:07:34 -04:00
..
cors.test.sh fix: scope CORS to browser routes only, require CORS_ORIGIN (fail closed) 2026-09-10 11:29:18 -04:00
digest-template.test.js fix(digest): replace hardcoded #7161FF with {{brandAccent}} 2026-09-10 11:23:31 -04:00
event-arrival-race.test.js fix digest job race: delete sent events by ID, not timestamp 2026-09-14 13:07:34 -04:00
integration.sh Merge remote-tracking branch 'origin/main' into mailship-0da-readme-config-architecture-and-docker-co-6e1 2026-09-14 12:55:35 -04:00
normalize-relay-url.test.js test: add failing test for normalizeRelayUrl(undefined) crash 2026-08-25 09:29:29 -04:00
reschedule-on-frequency-change.test.js fix: reschedule cron job when confirmed subscriber changes frequency 2026-09-10 11:30:56 -04:00
web-ui.test.js fix: guard normalizeRelayUrl against undefined env var 2026-08-24 18:21:00 -04:00