handle client disconnect

This commit is contained in:
henryruhs committed 2026-09-22 14:16:51 +02:00
1 parent d3ad762897
commit 074ea75ccd
1 file changed
+2 -1
+2 -1
View File
@@ -1,5 +1,6 @@
from json import JSONDecodeError
from starlette.requests import ClientDisconnect
from starlette.responses import JSONResponse
from starlette.status import HTTP_400_BAD_REQUEST
from starlette.types import ASGIApp, Receive, Scope, Send
@@ -11,7 +12,7 @@ def create_exception_guard(app : ASGIApp) -> ASGIApp:
async def middleware(scope : Scope, receive : Receive, send : Send) -> None:
try:
await app(scope, receive, send)
except JSONDecodeError:
except (ClientDisconnect, JSONDecodeError):
response = JSONResponse(
{
'message': translator.get('something_went_wrong', 'facefusion.apis')