fix(matrix): add backoff for SyncError in sync loop#3280
Merged
Conversation
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 28, 2026
The sync_loop now imports nio for SyncError checking (from PR #3280), so the test needs to inject a fake nio module via sys.modules.
teknium1
added a commit
that referenced
this pull request
Mar 28, 2026
* fix(matrix): harden e2ee access-token handling * fix: patch nio mock in e2ee maintenance sync loop test The sync_loop now imports nio for SyncError checking (from PR #3280), so the test needs to inject a fake nio module via sys.modules. --------- Co-authored-by: Cortana <andrew+cortana@chalkley.org>
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
Salvage of PR #2937 by @ticketclosed-wontfix, cherry-picked onto current main.
The bug
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) flooding logs and hammering the homeserver.The fix
Check the
sync()return value fornio.SyncErrorand sleep 5s before retrying, matching the existing exception-handling backoff. Theself._closingguard prevents delay during shutdown.Tests
Matrix adapter tests: 40 passed.
Closes #2937