diff --git a/src-new/astrbot_sdk/runtime/peer.py b/src-new/astrbot_sdk/runtime/peer.py index 5af890e69..531f348cf 100644 --- a/src-new/astrbot_sdk/runtime/peer.py +++ b/src-new/astrbot_sdk/runtime/peer.py @@ -102,6 +102,7 @@ class Peer: raise AstrBotError.protocol_error("initialize 必须收到 initialize_result") if not result.success: self._unusable = True + await self.stop() raise AstrBotError.from_payload(result.error.model_dump() if result.error else {}) output = InitializeOutput.model_validate(result.output) self.remote_peer = output.peer diff --git a/tests_v4/test_peer.py b/tests_v4/test_peer.py index 5ca26d44e..cad7aaa17 100644 --- a/tests_v4/test_peer.py +++ b/tests_v4/test_peer.py @@ -220,9 +220,9 @@ class PeerRuntimeTest(unittest.IsolatedAsyncioTestCase): self.assertEqual(raised.exception.code, "protocol_version_mismatch") await asyncio.wait_for(core.wait_closed(), timeout=1.0) + await asyncio.wait_for(plugin.wait_closed(), timeout=1.0) self.assertTrue(core._closed) - - await plugin.stop() + self.assertTrue(plugin._closed) class CapabilityRouterContractTest(unittest.TestCase):