Skip to content

fix(matrix): add backoff for SyncError in sync loop#3280

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-dfd0d467
Mar 26, 2026
Merged

fix(matrix): add backoff for SyncError in sync loop#3280
teknium1 merged 1 commit intomainfrom
hermes/hermes-dfd0d467

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

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 SyncError return value rather than raising an exception. The sync loop only had backoff logic in the except handler, so SyncError responses caused an immediate tight retry loop (~489 req/s) flooding logs and hammering the homeserver.

The fix

Check the sync() return value for nio.SyncError and sleep 5s before retrying, matching the existing exception-handling backoff. The self._closing guard prevents delay during shutdown.

Tests

Matrix adapter tests: 40 passed.

Closes #2937

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 teknium1 merged commit 148f466 into main Mar 26, 2026
1 of 2 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants