diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 3b4787120dd..cb854bcf0ad 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -857,7 +857,7 @@ class ConfigEntry: if self._on_unload is not None: while self._on_unload: if job := self._on_unload.pop()(): - self.async_create_task(hass, job) + self.async_create_task(hass, job, eager_start=True) if not self._tasks and not self._background_tasks: return diff --git a/tests/components/pi_hole/test_config_flow.py b/tests/components/pi_hole/test_config_flow.py index 0ab8b53744c..350b8b899d8 100644 --- a/tests/components/pi_hole/test_config_flow.py +++ b/tests/components/pi_hole/test_config_flow.py @@ -113,6 +113,7 @@ async def test_flow_reauth(hass: HomeAssistant) -> None: entry.add_to_hass(hass) with _patch_init_hole(mocked_hole), _patch_config_flow_hole(mocked_hole): assert not await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done() flows = hass.config_entries.flow.async_progress() diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index 5ce49308725..9e6e93cfe9e 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -4334,10 +4334,10 @@ async def test_task_tracking(hass: HomeAssistant) -> None: hass.loop.call_soon(event.set) await entry._async_process_on_unload(hass) assert results == [ - "on_unload", "background", "background", "normal", + "on_unload", ]