fix(matrix): add backoff for SyncError in sync loop#2937
Closed
ticketclosed-wontfix wants to merge 1 commit intoNousResearch:mainfrom
Closed
fix(matrix): add backoff for SyncError in sync loop#2937ticketclosed-wontfix wants to merge 1 commit intoNousResearch:mainfrom
ticketclosed-wontfix wants to merge 1 commit intoNousResearch:mainfrom
Conversation
When the homeserver returns an error response that matrix-nio parses as a SyncError (rather than raising an exception), the sync loop previously retried immediately with no delay. This created a tight retry loop (~489 req/s) flooding logs with 'next_batch is a required property' warnings and hammering the homeserver. Check the sync() return value for SyncError and sleep 5s before retrying, matching the existing exception-handling backoff.
teknium1
pushed a commit
that referenced
this pull request
Mar 26, 2026
When the homeserver returns an error response, matrix-nio parses it as a SyncError return value rather than raising an exception. The sync loop only had backoff in the except handler, so SyncError caused a tight retry loop (~489 req/s) flooding logs and hammering the homeserver. Check the return value and sleep 5s before retry. Cherry-picked from PR #2937 by ticketclosed-wontfix.
teknium1
added a commit
that referenced
this pull request
Mar 26, 2026
When the homeserver returns an error response, matrix-nio parses it as a SyncError return value rather than raising an exception. The sync loop only had backoff in the except handler, so SyncError caused a tight retry loop (~489 req/s) flooding logs and hammering the homeserver. Check the return value and sleep 5s before retry. Cherry-picked from PR #2937 by ticketclosed-wontfix. Co-authored-by: ticketclosed-wontfix <ticketclosed-wontfix@users.noreply.github.com>
Contributor
|
Merged via PR #3280. Your commit was cherry-picked onto current main with authorship preserved. Clean fix, thanks! |
StreamOfRon
pushed a commit
to StreamOfRon/hermes-agent
that referenced
this pull request
Mar 29, 2026
When the homeserver returns an error response, matrix-nio parses it as a SyncError return value rather than raising an exception. The sync loop only had backoff in the except handler, so SyncError caused a tight retry loop (~489 req/s) flooding logs and hammering the homeserver. Check the return value and sleep 5s before retry. Cherry-picked from PR NousResearch#2937 by ticketclosed-wontfix. Co-authored-by: ticketclosed-wontfix <ticketclosed-wontfix@users.noreply.github.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
When the Matrix homeserver returns an error response, matrix-nio parses it as a
SyncErrorreturn value rather than raising an exception. The sync loop only had backoff logic in theexcepthandler, soSyncErrorresponses caused an immediate tight retry loop (~489 req/s) that flooded logs with thousands of'next_batch' is a required propertywarnings per second and hammered the homeserver.Fix
Check the
sync()return value fornio.SyncErrorand sleep 5s before retrying, matching the existing exception-handling backoff.Reproduction
WARNING nio.responses: Error validating response: 'next_batch' is a required propertyTesting
SyncResponseobjects unchangedSyncErrorresponses now trigger a 5s backoff with a descriptive warningself._closingguard prevents 5s shutdown delay, matching existing pattern at line 561