Skip to content

hass_nabucasa has a race restarting the remote because ClientPeer.wait does not wait for task to finish #348

@bdraco

Description

@bdraco

It tries to make a connect task before the previous one is done

This was noticed by the assert added in #340

I've already fixed it in #344 but need to extract it into a new PR

Feb 09 13:49:21 homeassistant homeassistant[565]: 2025-02-09 07:49:21.895 DEBUG (MainThread) [snitun.client.client_peer] Opening connection to us-east-1-14.ui.nabu.casa:443
Feb 09 13:49:21 homeassistant homeassistant[565]: 2025-02-09 07:49:21.990 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Feb 09 13:49:21 homeassistant homeassistant[565]: Traceback (most recent call last):
Feb 09 13:49:21 homeassistant homeassistant[565]:   File "/usr/local/lib/python3.13/site-packages/hass_nabucasa/remote.py", line 497, in _reconnect_snitun
Feb 09 13:49:21 homeassistant homeassistant[565]:     await self.connect()
Feb 09 13:49:21 homeassistant homeassistant[565]:   File "/usr/local/lib/python3.13/site-packages/hass_nabucasa/remote.py", line 422, in connect
Feb 09 13:49:21 homeassistant homeassistant[565]:     await self._snitun.connect(
Feb 09 13:49:21 homeassistant homeassistant[565]:     ...<4 lines>...
Feb 09 13:49:21 homeassistant homeassistant[565]:     )
Feb 09 13:49:21 homeassistant homeassistant[565]:   File "/usr/local/lib/python3.13/site-packages/snitun/utils/aiohttp_client.py", line 91, in connect
Feb 09 13:49:21 homeassistant homeassistant[565]:     await self._client.start(
Feb 09 13:49:21 homeassistant homeassistant[565]:     ...<5 lines>...
Feb 09 13:49:21 homeassistant homeassistant[565]:     )
Feb 09 13:49:21 homeassistant homeassistant[565]:   File "/usr/local/lib/python3.13/site-packages/snitun/client/client_peer.py", line 124, in start
Feb 09 13:49:21 homeassistant homeassistant[565]:     assert not self._handler_task, "SniTun connection already running"
Feb 09 13:49:21 homeassistant homeassistant[565]:            ^^^^^^^^^^^^^^^^^^^^^^
Feb 09 13:49:21 homeassistant homeassistant[565]: AssertionError: SniTun connection already running

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions