feat(timeout): prevent Cloudflare 524 timeouts on long generations via SSE heartbeats and chunked keep-alives

This commit is contained in:
tyuXX 2026-11-03 17:55:26 +00:00
parent ba57e3e394
commit 0e83233715
7 changed files with 385 additions and 25 deletions

View file

@ -16,6 +16,17 @@ LOG_DIR=./logs
# Rate limit configuration (duration in milliseconds)
RATE_LIMIT_DURATION_MS=60000
# Cloudflare Anti-Timeout Configuration
# Interval (in ms) to send SSE comment heartbeats during streaming (: keep-alive)
# KEEPALIVE_INTERVAL_MS=15000
# Enable chunked whitespace keep-alives for non-streaming requests exceeding delay
# ENABLE_NON_STREAMING_KEEPALIVE=true
# NON_STREAMING_KEEPALIVE_DELAY_MS=20000
# Candidate timeout per provider attempt before rotating (in ms)
# CANDIDATE_TIMEOUT_MS=60000
# Cloudflare Tunnel configuration (for Docker deployment)
# Get your tunnel token from: https://dash.cloudflare.com/
CLOUDFLARE_TUNNEL_TOKEN=your_cloudflare_tunnel_token_here