Home Assistant crashes every day

Almost every day my home assistant crashes and this is the log I can see:

2023-02-13 16:59:54.485 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/hass_nabucasa/remote.py", line 395, in _reconnect_snitun
    await self._snitun.wait()
  File "/usr/local/lib/python3.10/site-packages/snitun/multiplexer/core.py", line 132, in _runner
    async with async_timeout.timeout(PEER_TCP_TIMEOUT):
  File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 120, in __aenter__
    self._do_enter()
  File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 207, in _do_enter
    self._reschedule()
  File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 201, in _reschedule
    self._timeout_handler = self._loop.call_at(deadline, self._on_timeout, task)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 736, in call_at
    heapq.heappush(self._scheduled, timer)
RuntimeError: list changed size during iteration
2023-02-13 16:59:54.494 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/snitun/client/client_peer.py", line 135, in _handler
    await self._multiplexer.wait()
  File "/usr/local/lib/python3.10/site-packages/snitun/multiplexer/core.py", line 132, in _runner
    async with async_timeout.timeout(PEER_TCP_TIMEOUT):
  File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 120, in __aenter__
    self._do_enter()
  File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 207, in _do_enter
    self._reschedule()
  File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 201, in _reschedule
    self._timeout_handler = self._loop.call_at(deadline, self._on_timeout, task)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 736, in call_at
    heapq.heappush(self._scheduled, timer)
RuntimeError: list changed size during iteration
2023-02-13 17:00:59.495 ERROR (MainThread) [root] Uncaught exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 226, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 214, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 128, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 633, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 600, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1869, in _run_once
    handle = heapq.heappop(self._scheduled)
RuntimeError: list changed size during iteration

Can somebody help me to find where is the problem?

Start by disabling your third party integrations. It is very likely one of them.

You mean custom components?
And how to know which one is causing this? I have many of them like, i think, most people here…

You have to disable them one by one and figure it out. The errors in the logs do not point to the troublesome custom component.

Or turn them all off and make sure you’re stable at that point, then turn one at a time back on until you experience the issue. Or turn half of them off and see if you’re stable, then half of those, etc… all as a means to narrow down to which component is causing the issue.

1 Like

that’s the best way. Half at a time will narrow it down quickly.

And while the folder is still called custom_components for backward compatibility they are called custom integrations now and has been for a very long time.