Skip to content

Handle TimeoutError gracefully to prevent blocking HA startup#387

Merged
sebr merged 1 commit intomainfrom
timeout-error-handling
Apr 14, 2026
Merged

Handle TimeoutError gracefully to prevent blocking HA startup#387
sebr merged 1 commit intomainfrom
timeout-error-handling

Conversation

@sebr
Copy link
Copy Markdown
Owner

@sebr sebr commented Apr 14, 2026

Summary

Fixes #370

  • Wraps TimeoutError from aiohttp requests in RequestError at the API client level (client.py), converting it into the BHyveError hierarchy so all existing error handlers catch it automatically
  • Adds defense-in-depth TimeoutError handling at the integration setup (__init__.py), coordinator (coordinator.py), and options flow (config_flow.py) layers
  • Transient API timeouts during startup now raise ConfigEntryNotReady, which tells HA to retry with exponential backoff instead of blocking startup
  • Transient API timeouts during polling raise UpdateFailed, which preserves the last known cached data and retries at the next coordinator interval — entities stay available with slightly stale data

Test plan

  • Existing tests pass (133 passed, 5 skipped)
  • Linting passes
  • Verify HA starts normally when B-hyve API is temporarily unreachable
  • Verify entities recover and update once the API becomes available again

Catch TimeoutError from aiohttp requests and convert to RequestError
at the API client level, with defense-in-depth handling at the
coordinator and integration setup layers. Transient API timeouts now
result in ConfigEntryNotReady (auto-retry) during setup and
UpdateFailed (cached data preserved) during polling.
@sebr sebr merged commit 22f9a11 into main Apr 14, 2026
4 checks passed
@sebr sebr deleted the timeout-error-handling branch April 14, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seems to have broken my HAOS (didn't change anything, was working fine prior)

1 participant