fix: add SSE padding to flush Cloudflare tunnel buffers for real-time events

Cloudflare quick tunnels buffer small SSE responses, causing tab creation
and other UI events to arrive late on mobile. Adds ~8KB SSE comment padding
(ignored by EventSource) to force the proxy to flush immediately.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-03-01 18:24:14 +01:00
co-authored by Claude Opus 4.6
parent 8764a684ac
commit 2b61a8db1b
2 changed files with 29 additions and 9 deletions
+9 -2
View File
@@ -21,8 +21,15 @@ export const BATCH_FLUSH_THRESHOLD = 32 * 1024;
/** Task event batching interval (ms) */
export const TASK_UPDATE_BATCH_INTERVAL = 100;
/** SSE client health check interval (ms) */
export const SSE_HEALTH_CHECK_INTERVAL = 30 * 1000;
/** SSE heartbeat interval — sends padded keepalive to flush proxy buffers (ms).
* 15s is fast enough to keep Cloudflare tunnel buffers flushed while avoiding
* excessive bandwidth. Also serves as dead-client detection. */
export const SSE_HEARTBEAT_INTERVAL = 15 * 1000;
/** SSE padding size (bytes). Cloudflare quick tunnels buffer small SSE events;
* appending ~8KB of SSE comment padding forces the proxy to flush immediately.
* SSE comments (lines starting with ':') are silently ignored by EventSource. */
export const SSE_PADDING_SIZE = 8 * 1024;
// ============================================================================
// State Persistence