fix(matrix): isolate per-event failures in _dispatch_sync gather - #57643
Closed
Que0x wants to merge 1 commit into
Closed
fix(matrix): isolate per-event failures in _dispatch_sync gather#57643Que0x wants to merge 1 commit into
Que0x wants to merge 1 commit into
Conversation
`_dispatch_sync` gathers the mautrix per-event handler tasks with a bare `asyncio.gather(*tasks)`. Without `return_exceptions=True`, the first handler that raises aborts the gather, so the sibling events in the same sync response are dropped unprocessed — the exception propagates up to the sync loop, which logs a single "sync error" and moves on. The invite/redaction gathers a few lines above already use `return_exceptions=True`. Use `return_exceptions=True` and log each failing handler, so one bad event no longer takes out the rest of its batch and per-event failures stay visible. Regression test: a batch with one failing and one succeeding handler no longer raises, the good handler still runs, and the failure is logged (mutation- verified — reverting re-raises RuntimeError out of _dispatch_sync).
Contributor
|
Merged via PR #57660 — your commit was cherry-picked onto current main with your authorship preserved in git log (rebase-merge). Thanks for the fix! |
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.
What does this PR do?
_dispatch_syncgathers the mautrix per-event handler tasks with a bareasyncio.gather(*tasks). Withoutreturn_exceptions=True, the first handlerthat raises aborts the gather, so the sibling events in the same sync response
are dropped unprocessed — the exception propagates to the sync loop, which
logs one "sync error" and moves on to the next batch. The invite/redaction
gathers a few lines above already use
return_exceptions=True.Use
return_exceptions=Trueand log each failing handler, so one bad event nolonger takes out the rest of its batch and per-event failures stay visible.
Changes
plugins/platforms/matrix/adapter.py—_dispatch_syncgathers withreturn_exceptions=Trueand logs any handler exceptions.tests/gateway/test_matrix.py— addTestMatrixDispatchSyncIsolation.Tests
A sync batch with one failing + one succeeding handler no longer raises, the
good handler still runs, and the failure is logged. Mutation-verified: reverting
the change re-raises
RuntimeErrorout of_dispatch_sync.