Skip to content

fix(homeassistant): bound every wedgeable await during connect and teardown - #80372

Open
Sora-bluesky wants to merge 1 commit into
NousResearch:mainfrom
Sora-bluesky:fix/issue-67470-bounded
Open

fix(homeassistant): bound every wedgeable await during connect and teardown#80372
Sora-bluesky wants to merge 1 commit into
NousResearch:mainfrom
Sora-bluesky:fix/issue-67470-bounded

Conversation

@Sora-bluesky

Copy link
Copy Markdown
Contributor

This is the first half of the split I promised in #68540: the bounded-await hardening alone, without the watchdog machinery.

The problem (#67470): the HA adapter could go silently deaf. Several awaits in the connect/teardown path had no bound, so a wedged WebSocket close or a hung auth handshake left the adapter stuck forever while the gateway still reported "running".

What this PR does:

  • _ws_connect() now builds the session into a local first and closes it on failure or cancellation (the session leak egilewski probed in fix(homeassistant): bound every wedgeable await and watchdog the listener #68540), and bounds all three auth handshake steps with _HANDSHAKE_TIMEOUT
  • in teardown (disconnect() / _full_teardown() / _cleanup_ws()), every close and cancel is bounded by _DRAIN_TIMEOUT, and a close survives a second cancellation racing in while it is still running (the close detaches and is tracked in _teardown_tasks)
  • a module-level _run_bounded_close() primitive plus a _cancel_task_bounded() adapter method, which the follow-up PR reuses

This PR does not add the watchdog or stall detection. That is the second half (watchdog plus stale-generation guard). It builds on these primitives and comes as a separate PR once this one lands.

Verification:

#68540 stays open for reference. Happy to close it once both halves are in, or however you prefer to handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants