From 49dd8da5ed342d5fdfb0f198278b54662acea91b Mon Sep 17 00:00:00 2001 From: npeter83 Date: Thu, 18 Jun 2026 15:13:01 +0200 Subject: [PATCH] fix(api): raise uvicorn keepalive above the proxy reuse window uvicorn's default --timeout-keep-alive is 5s, shorter than Caddy's pooled keepalive idle window, so the proxy reused connections uvicorn had just closed -> broken pipe / connection reset -> 502. The player's progress/state POSTs fire every 5s (resonant with the 5s default) and, being non-idempotent, could not be auto-retried by the proxy, so those 502s reached the user. Set --timeout-keep-alive 75 so the upstream outlives the proxy's reuse. --- backend/entrypoint.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index ce6a6c8..04ac8af 100644 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -5,4 +5,9 @@ echo "Applying database migrations..." alembic upgrade head echo "Starting Siftlode API..." -exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --log-config log_config.json +# --timeout-keep-alive 75: keep idle upstream connections alive longer than the reverse +# proxy's idle-reuse window. uvicorn's default (5s) is shorter than Caddy's pooled-keepalive +# timeout, so Caddy would reuse a connection uvicorn had just closed -> broken pipe / reset +# on the next request -> 502. Non-idempotent POSTs (the player's progress/state writes, +# fired every 5s) can't be auto-retried by the proxy, so those 502s reached the user. +exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --log-config log_config.json --timeout-keep-alive 75