Skip to content

Handle connection errors during event writes#48

Open
teancom wants to merge 1 commit intoOHF-Voice:mainfrom
teancom:fix/connection-errors
Open

Handle connection errors during event writes#48
teancom wants to merge 1 commit intoOHF-Voice:mainfrom
teancom:fix/connection-errors

Conversation

@teancom
Copy link

@teancom teancom commented Mar 3, 2026

I see this error pretty much every time I restart the openWakeWord app in Home Assistant:

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='wyoming event handler' coro=<AsyncEventHandler.run() done, defined at /usr/local/lib/python3.11/dist-packages/wyoming/server.py:31> exception=ConnectionResetError('Connection lost')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/wyoming/server.py", line 41, in run
    if not (await self.handle_event(event)):
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/wyoming_openwakeword/handler.py", line 62, in handle_event
    await self.write_event(info.event())
  File "/usr/local/lib/python3.11/dist-packages/wyoming/server.py", line 29, in write_event
    await async_write_event(event, self.writer)
  File "/usr/local/lib/python3.11/dist-packages/wyoming/event.py", line 136, in async_write_event
    await writer.drain()
  File "/usr/lib/python3.11/asyncio/streams.py", line 378, in drain
    await self._protocol._drain_helper()
  File "/usr/lib/python3.11/asyncio/streams.py", line 167, in _drain_helper
    raise ConnectionResetError('Connection lost')
ConnectionResetError: Connection lost
[16:53:33] INFO: Successfully sent discovery information to Home Assistant.

Did a bit of digging, tracked it down to this. Commit message follows.

Add exception handling for ConnectionResetError, ConnectionError, and BrokenPipeError in both AsyncEventHandler.run() and async_write_event() to prevent "Task exception was never retrieved" errors when clients disconnect. Client disconnects are normal and shouldn't be treated as exceptional conditions.

Add exception handling for ConnectionResetError, ConnectionError, and
BrokenPipeError in both AsyncEventHandler.run() and async_write_event()
to prevent "Task exception was never retrieved" errors when clients
disconnect. Client disconnects are normal and shouldn't be treated as
exceptional conditions.
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.

1 participant