Suppress Matrix timeout errors in console (fixes #835) #887
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.
Description
The Matrix connector will often receive a timeout error when doing a sync request. The catch-all except would just dump the entire HTML of the timeout response to the console. This output can be quite voluminous and not that useful. By checking for know timeout error codes we can suppress the useless HTML output and just log the occurrence at the info level for those that are interested to know when timeouts occur.
In addition to the standard
504 Gateway Timeout
error we also check for522 Connection timed out
and524 A Timeout Error
which are timeout errors specific to Cloudflare. See:https://support.cloudflare.com/hc/en-us/articles/115003011431/
We check for these Cloudflare errors because the largest Matrix host (matrix.org) is fronted by Cloudflare.
Fixes #835
Status
READY
Type of change
How Has This Been Tested?
As far as I can tell there are no existing tests covering this part of the codebase, but the changes have been tested against the matrix.org homeserver using Python 3.7.2+ (Debian testing).
Checklist: