diff --git a/astrbot/core/core_lifecycle.py b/astrbot/core/core_lifecycle.py index cb9fb9191..9a4ba1320 100644 --- a/astrbot/core/core_lifecycle.py +++ b/astrbot/core/core_lifecycle.py @@ -279,6 +279,9 @@ class AstrBotCoreLifecycle: # Leave other runtime initializations (plugin reload, provider init, etc.) # to `bootstrap_runtime`. + # Initialize dashboard shutdown event (matches full initialize behavior) + self.dashboard_shutdown_event = asyncio.Event() + async def bootstrap_runtime(self) -> None: """Compatibility method for runtime bootstrap (deferred initialization). @@ -340,6 +343,9 @@ class AstrBotCoreLifecycle: "Failed cleaning up plugins after runtime bootstrap failure", ) + # Reset event_bus to None so callers can detect partial init + self.event_bus = None + try: if getattr(self, "provider_manager", None) and hasattr( self.provider_manager, diff --git a/tests/unit/test_core_lifecycle.py b/tests/unit/test_core_lifecycle.py index e253ccd7c..a719c51c2 100644 --- a/tests/unit/test_core_lifecycle.py +++ b/tests/unit/test_core_lifecycle.py @@ -722,10 +722,10 @@ class TestAstrBotCoreLifecycleInitialize: ) mocks["create_task"].side_effect = record_create_task + lifecycle.load_pipeline_scheduler = load_pipeline_scheduler + with patch_initialize_test_mocks(mock_astrbot_config, mocks): await lifecycle.initialize_core() - - await lifecycle.bootstrap_runtime() assert call_order == [