fix(gateway): stop Mattermost/Matrix reconnect loop on permanent auth failures#3695
Open
binhnt92 wants to merge 1 commit intoNousResearch:mainfrom
Open
fix(gateway): stop Mattermost/Matrix reconnect loop on permanent auth failures#3695binhnt92 wants to merge 1 commit intoNousResearch:mainfrom
binhnt92 wants to merge 1 commit intoNousResearch:mainfrom
Conversation
…ures Mattermost's _ws_loop and Matrix's _sync_loop both catch all exceptions with a broad except Exception and retry with backoff forever. When the auth token is invalid or revoked (401/403, M_UNKNOWN_TOKEN), these loops spin indefinitely instead of stopping — wasting resources and flooding logs with retry warnings. Detect permanent auth errors (HTTP 401/403, WSServerHandshakeError, M_UNKNOWN_TOKEN, M_FORBIDDEN) and stop the reconnect/sync loop immediately instead of retrying.
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.
Mattermost's
_ws_loopand Matrix's_sync_loopboth catch all exceptions with a broadexcept Exceptionand retry with backoff forever. When the auth token is invalid or revoked (HTTP 401/403,M_UNKNOWN_TOKEN), these loops spin indefinitely — burning resources and flooding logs with retry warnings that will never succeed.This is the same pattern that PR #3390 fixed for Telegram's
message_thread_idmisclassification: distinguishing permanent errors from transient ones instead of retrying everything.Changes Made
Mattermost (
gateway/platforms/mattermost.py):aiohttp.WSServerHandshakeErrorwith status 401/403unauthorized,401,403)Matrix (
gateway/platforms/matrix.py):M_UNKNOWN_TOKENandM_FORBIDDENinnio.SyncErrorresponsesTransient errors (network timeouts, connection resets) still retry with backoff as before.
How to Test
6 tests covering: 401 stops Mattermost, 403 stops Mattermost, transient retries Mattermost, M_UNKNOWN_TOKEN stops Matrix, 401 stops Matrix, transient retries Matrix.
Checklist