Retry setup on transient network errors instead of failing permanently - #603
Open
jaypopat wants to merge 1 commit into
Open
Retry setup on transient network errors instead of failing permanently#603jaypopat wants to merge 1 commit into
jaypopat wants to merge 1 commit into
Conversation
async_setup_entry converts meross_iot exceptions into ConfigEntryNotReady or ConfigEntryAuthFailed, but transport errors raised by aiohttp are not handled. They propagate out of async_setup_entry, so HomeAssistant marks the entry SETUP_ERROR and never retries it. The integration then stays down until the user reloads it by hand. This triggers whenever the cloud is briefly unreachable at setup time, most often when HomeAssistant starts before the network is ready and the first devList call fails on DNS. Catch aiohttp.ClientError and asyncio.TimeoutError in initial_setup and async_setup_entry and raise ConfigEntryNotReady, so setup is retried with backoff. aiohttp.ClientError covers both reported variants, ClientConnectorDNSError and ClientConnectorError. Fixes albertogeniola#599
jaypopat
force-pushed
the
fix/retry-setup-on-transient-network-errors
branch
from
August 24, 2026 19:36
c7e6836 to
1bd9e3d
Compare
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.
Problem
async_setup_entryconvertsmeross_iotexceptions intoConfigEntryAuthFailedorConfigEntryNotReady, but transport errors raised byaiohttpare not handled. They propagate out ofasync_setup_entry, so HomeAssistant marks the entrySETUP_ERROR. That state is never retried, since onlyConfigEntryNotReadytriggers retry with backoff, so the integration stays down until the user reloads it by hand.A momentary network hiccup at startup therefore takes the integration offline indefinitely. The usual trigger is HomeAssistant starting before the network is ready, so the first
devListcall fails on DNS:One attempt, zero retries. On my install it sat in
SETUP_ERRORfor three days after a host reboot with every Meross deviceunavailable, while other cloud integrations that hit the same blip at the same moment recovered on their own.#599 reports the same failure with an identical traceback (same lines 420, 144, 342) and
ClientConnectorError, which is the WAN-drop variant of the same bug.Fix
Catch
aiohttp.ClientErrorandasyncio.TimeoutErrorininitial_setupandasync_setup_entry, and raiseConfigEntryNotReadyso HomeAssistant retries with backoff.aiohttp.ClientErroris the common ancestor of both reported variants,ClientConnectorDNSErrorandClientConnectorError, as well asClientOSErrorandServerTimeoutError.Authentication handling is unchanged, so bad credentials still stop rather than retry forever.
Testing
Verified against the aiohttp shipped with current HomeAssistant (3.14.3) that all four variants above are caught by
aiohttp.ClientError.Confirmed the recovery path on a live 1.3.12 install: the entry had been in
SETUP_ERRORsince a reboot three days earlier and came back immediately on a config entry reload, which is whatConfigEntryNotReadywould have done automatically.I did not fault inject a DNS failure against the patched code, as that would have meant deliberately breaking name resolution on a production setup. Happy to add that if you would like it verified that way.