Fix satellite dashboard page never loading by sending immediate SSE keepalive

Werkzeug's dev server buffers SSE response headers until the first body byte
is written. With keepalive_interval=30s, opening two SSE connections on
DOMContentLoaded (satellite stream + new ground station stream) meant the
browser waited 30 seconds before receiving any response bytes from either
connection. Browsers keep their loading indicator active while connections are
pending, causing the satellite dashboard to appear stuck loading.

Fix: yield an immediate keepalive at the start of sse_stream_fanout so every
SSE endpoint flushes headers + first data to the browser instantly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
James Smith
2026-03-18 20:03:07 +00:00
parent 8d8ee57cec
commit f043baed9f

View File

@@ -152,6 +152,10 @@ def sse_stream_fanout(
)
last_keepalive = time.time()
# Send an immediate keepalive so the browser receives response headers
# right away (Werkzeug dev server buffers headers until first body byte).
yield format_sse({'type': 'keepalive'})
try:
while True:
if stop_check and stop_check():