Conversation
logger.error() calls inside TelegramSender's exception handling were picked up by the root-attached ErrorBroadcastHandler and re-sent to error_logs_recipients. When that broadcast itself failed (e.g. Telegram flood control), the failure was logged the same way, causing an unbounded feedback loop of error messages to the same chat. Mark these specific logs with skip_broadcast so delivery failures are logged locally but no longer re-enter the broadcast pipeline. Co-Authored-By: Claude Sonnet 5 <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.
Summary
ErrorBroadcastHandleris attached to the root logger, so anylogger.error()call in the app gets forwarded to Telegram viaTelegramSender.send_error_log().TelegramSender's own send-failure handling usedlogger.error(), including when redirecting a failed message toerror_logs_recipientsitself failed — creating a feedback loop: failed send → broadcast to error chat → that send fails (e.g. flood control) → logged as error → broadcast again → ... This produced the observed storm of hundreds ofRetryAfter/PoolTimeoutmessages to the same chat.skip_broadcastmarker respected byErrorBroadcastHandler.emit(), set on the threelogger.error()calls insideTelegramSender's own exception handling. Failures still log locally and the original message is still explicitly forwarded toerror_logs_recipients, but the failure-to-notify no longer re-enters the broadcast pipeline.Test plan
pytest tests/unit— all pass except one pre-existing unrelated failure (test_scheduler.py::test_jobs_executed, confirmed failing ondevbefore this change too)