mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-18 14:46:30 +00:00
Avoid exception when handling closed WebSocket connection
When delivering multiple messages to Core, and the first fails with a connection error, the second message will also fail with the same error. But at this point the connection is already clsoed, which leads to an exception in the exception handler. Avoid this compunding error by checking if the connection is still exists before trying to close. Fixes: #5629
This commit is contained in:
parent
2cb2a48184
commit
3d74d2bb7c
@ -266,6 +266,7 @@ class HomeAssistantWebSocket(CoreSysAttributes):
|
||||
try:
|
||||
await self._client.async_send_command(message)
|
||||
except HomeAssistantWSConnectionError:
|
||||
if self._client:
|
||||
await self._client.close()
|
||||
self._client = None
|
||||
|
||||
@ -277,6 +278,7 @@ class HomeAssistantWebSocket(CoreSysAttributes):
|
||||
try:
|
||||
return await self._client.async_send_command(message)
|
||||
except HomeAssistantWSConnectionError:
|
||||
if self._client:
|
||||
await self._client.close()
|
||||
self._client = None
|
||||
raise
|
||||
|
Loading…
x
Reference in New Issue
Block a user