fix(dashboard): suppress benign SSL close notify errors

When clients disconnect abruptly, hypercorn raises
ssl.SSLError APPLICATION_DATA_AFTER_CLOSE_NOTIFY during SSL shutdown.
This is benign and expected behavior. Wrap serve() with
try/except to suppress these spurious errors.
This commit is contained in:
LIghtJUNction
2026-03-24 19:08:09 +08:00
parent 16f8cdea92
commit 4cc700f57d

View File

@@ -6,6 +6,7 @@ import os
import platform
import re
import socket
import ssl
from collections.abc import Callable
from datetime import datetime
from ipaddress import IPv4Address, IPv6Address, ip_address
@@ -584,7 +585,11 @@ class AstrBotDashboard:
config.accesslog = "-"
config.access_log_format = "%(h)s %(r)s %(s)s %(b)s %(D)s"
await serve(self.app, config, shutdown_trigger=self.shutdown_trigger)
try:
await serve(self.app, config, shutdown_trigger=self.shutdown_trigger)
except (ssl.SSLError, asyncio.CancelledError):
# Client disconnected abruptly — SSL shutdown errors are benign.
pass
@staticmethod
def _build_bind(host: str, port: int) -> str: