Repository navigation
Retry when the device or cloud is briefly unavailable - #1196
Merged
Merged
Conversation
Since passing on the error messages of the device and the cloud, every error response raised a LaMetricError that was never retried. A brief 502, 503 or 504 from the cloud now failed right away, where it used to be retried. Home Assistant only treats connection errors as "cannot connect", so people got an unknown error instead. Those three statuses are connection errors again. Reads retry them, changes do not, as the device may already have acted on them. aiohttp's ConnectionTimeoutError now also counts as never sent, as it is only raised while the connection is still being made.
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.
Proposed Changes
Found in a review of everything that changed since v1.4.1, checked against how Home Assistant uses the library.
Transient errors were no longer retried. In v1.4.1 both clients used
raise_for_status=True, so an error response became aClientResponseError, turned into aLaMetricConnectionError, and was retried. Since #1181 every error response raises a plainLaMetricErrorwith the message of the server, which is never retried. A brief 502, 503 or 504 from the cloud now failed setup on the first try, and because Home Assistant's config flow only catchesLaMetricConnectionError, people got "unknown" instead of "cannot connect".502, 503 and 504 now raise a
LaMetricConnectionErroragain, saying the device or cloud is temporarily unavailable. Reads retry them like before. Changes to the device do not, following #1186: the device may already have acted on them. Other error responses still raise right away.aiohttp.ConnectionTimeoutErrorcounts as never sent. aiohttp only raises it while the connection is still being made, so a change cannot have reached the device yet and is safe to retry.The tests for retrying changes now run for POST, PUT and DELETE, so a check on the method that only covers POST would no longer slip through.
Related Issues
Follow up on #1181 and #1186.