Commit bb94316
fix(mail): stop CLI email loops spinning on users that fail to load
When looking up a user threw, sendEmails() skipped the user without
removing their queue entries. Since getAffectedUsers() always returns
the users with the oldest pending items first, and both EmailNotification
(cron) and the send-emails command loop while a full batch was reported,
a full batch of users with a broken user backend made those loops spin
on the same batch forever, retrying and logging endlessly within one run.
Report the number of users actually dealt with instead of the number of
affected users, so a batch containing failed lookups ends the loop and
the skipped users are retried on the next run. This also matches the
documented return value. Entries of users that fail to load are still
kept for retry: a lookup for a deleted user returns null (handled via
the empty-email path), a throw indicates a temporarily broken backend
and pending emails should not be discarded because of it.
Signed-off-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 6ae4d1f commit bb94316
1 file changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
140 | 143 | | |
141 | 144 | | |
142 | 145 | | |
| |||
0 commit comments