fix: Handle connection errors when stopping node console

Add exception handling in stop_wrap_console to gracefully handle
ConnectionResetError, BrokenPipeError, and OSError when waiting
for console writer to close.

This prevents 500 errors when stopping QEMU nodes if the console
connection is reset before the writer finishes closing.

Fixes race condition where QEMU process exits and closes connections
before the console writer cleanup completes.
This commit is contained in:
YueGuobin 2026-05-08 23:26:00 +08:00
parent e0860555ba
commit 3752b2bac8
No known key found for this signature in database

View File

@ -474,10 +474,18 @@ class BaseNode:
if self._wrap_console_writer:
self._wrap_console_writer.close()
await self._wrap_console_writer.wait_closed()
try:
await self._wrap_console_writer.wait_closed()
except (ConnectionResetError, BrokenPipeError, OSError):
# Connection already closed, ignore error
pass
for telnet_proxy_server in self._wrapper_telnet_servers:
telnet_proxy_server.close()
await telnet_proxy_server.wait_closed()
try:
await telnet_proxy_server.wait_closed()
except (ConnectionResetError, BrokenPipeError, OSError):
# Connection already closed, ignore error
pass
self._wrapper_telnet_servers = []
async def reset_wrap_console(self):