fix(homeassistant): bound every wedgeable await during connect and teardown - #80372
Open
Sora-bluesky wants to merge 1 commit into
Open
fix(homeassistant): bound every wedgeable await during connect and teardown#80372Sora-bluesky wants to merge 1 commit into
Sora-bluesky wants to merge 1 commit into
Conversation
13 tasks
Open
1 task
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.
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_TIMEOUTdisconnect()/_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)_run_bounded_close()primitive plus a_cancel_task_bounded()adapter method, which the follow-up PR reusesThis 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:
_ws_connectmakes 3 tests fail, restoring it goes green#68540 stays open for reference. Happy to close it once both halves are in, or however you prefer to handle it.