Repository navigation
Stop the email loop when error email delivery fails - #104
Merged
Merged
Conversation
A delivery failure was reported like any other error, which created an occurrence, which sent another email, which failed again. The mailer now reports its own failures with emails switched off for that report. Fixes #89. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #89.
When the error email fails to deliver (bad SMTP credentials, a host that's down), the failed delivery job's exception is reported through
Rails.error. That creates an occurrence, the occurrence enqueues another error email, that email fails too, and the cycle never ends.ErrorMailernow handles its own failures withrescue_from StandardError. That covers rendering errors as well as delivery errors, because ActionMailer routes delivery throughhandle_exceptions. It reports the exception insideSolidErrors.without_emails, a block during whichsend_emails?is false for the current thread or fiber. So:Rails.errorsubscriber, but nothing emails about it;Trade-off: the delivery job no longer re-raises, so ActiveJob won't retry a transient SMTP failure for that one email. Retrying is what kept the loop going, and the failure stays visible in the dashboard.
Tests use a delivery method that always fails. Without the fix, the delivery error escapes the job and both new tests error.
🤖 Generated with Claude Code