From d8d301a13f00ab373525613f16ca0a8b04c82779 Mon Sep 17 00:00:00 2001 From: Claus Lohmar Date: Wed, 22 Jul 2026 05:12:21 +0000 Subject: [PATCH] debug: add request-logging middleware + make upload handler sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - HTTP middleware logs every incoming request (method, path, body size) BEFORE handler runs — catches silent failures at the network/parser layer - Changed upload handler from async to sync so FastAPI runs it in a thread pool, preventing event loop blockage during large file reads --- frontend/app.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/app.py b/frontend/app.py index 7687b5f..06dbb0b 100644 --- a/frontend/app.py +++ b/frontend/app.py @@ -40,6 +40,18 @@ from api_client import ApiClient, ApiError, BACKEND_URL # --------------------------------------------------------------------------- app = FastAPI(title="VM Bench — Frontend", version="1.0.0") +# ── Request logging middleware (logs before handler, catches silent failures) ── +@app.middleware("http") +async def log_requests(request: Request, call_next): + cl = request.headers.get("content-length", "?") + logger.info("→ %s %s (body %s bytes)", request.method, request.url.path, cl) + try: + response = await call_next(request) + return response + except Exception: + logger.exception("← %s %s FAILED", request.method, request.url.path) + raise + BASE = Path(__file__).parent app.mount("/static", StaticFiles(directory=str(BASE / "static")), name="static") @@ -117,7 +129,7 @@ async def index(request: Request, vmid: Optional[int] = None, source: Optional[s @app.post("/session/upload") -async def session_upload( +def session_upload( request: Request, vmid: int = Form(...), vm_name: str = Form(""),