Home-Assistant-Mail-And-Packages
Home-Assistant-Mail-And-Packages copied to clipboard
ISSUE: Blocking call event loop during package initialization causes HA to hang
Describe the bug Mail-and-packages freezes during initialization (after I successfully link my gMail account and select my folder + sensors). Home Assistant reports an event loop, freezes, and must be restarted. Home Assistant no longer boots with the last log entry on boot attempts being "2024-06-25 23:12:57.286 ERROR (MainThread) [custom_components.mail_and_packages.helpers] Error searching emails: command: SEARCH => unexpected response: b'7csp12957rwo;'" Removing the mail-and-packages from the custom_components directory allowed me to boot, disable and then remove the integration. 100% reproducable.
Environment (please complete the following information):
- OS: Docker
- Type of device: Dedicated server hardware, Xeon E-2386G x6 core, 64 GB DDR4
- Home Assistant version: 2024.06.4
- Docker
- Component version: v0.3.29
Logs
2024-06-25 23:07:19.056 ERROR (MainThread) [custom_components.mail_and_packages] Problem updating sensors: 'count'
2024-06-25 23:07:19.056 ERROR (MainThread) [custom_components.mail_and_packages] Error fetching Mail and Packages (imap.gmail.com) data: 'count'
2024-06-25 23:07:19.056 ERROR (MainThread) [custom_components.mail_and_packages] Error updating sensor data: 'count'
2024-06-25 23:07:19.603 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open inside the event loop by custom integration 'mail_and_packages' at custom_components/mail_and_packages/helpers.py, line 1171: with open(filepath, "wb") as the_file: (offender: /config/custom_components/mail_and_packages/helpers.py, line 1171: with open(filepath, "wb") as the_file:), please create a bug report at https://github.com/moralmunky/Home-Assistant-Mail-And-Packages/issues
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
sys.exit(main())
File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
exit_code = runner.run(runtime_conf)
File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
self._run_once()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once
handle._run()
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/config/custom_components/mail_and_packages/helpers.py", line 1171, in download_img
with open(filepath, "wb") as the_file:
2024-06-25 23:07:25.271 ERROR (SyncWorker_26) [custom_components.mail_and_packages.helpers] Error fetching emails: command: FETCH => unexpected response: b'7csp12957rwo;'
Additional context I had this working originally for over a year, upgraded mail-and-packages through HACS and had an issue (I forget what the issue was). As part of troubleshooting I uninstalled the package, restarted HA, re-installed this package and now am facing this issue preventing HA from booting. 100% reproducible.
I've linked it to gMail, see my directories, select "Home/Mail" (which is where I filter all my package emails). I've selected all sensors for Amazon, DHL, FedEx, plus the last two sensors regarding summaries.