Fix SSE first-byte delay in ADS-B and controller streams; harden WebSocket init

- Add immediate keepalive to /adsb/stream generator so the Werkzeug dev
  server flushes response headers immediately on tracking start, preventing
  the 30-second delay before the aircraft map begins receiving data
- Same fix for /controller/stream/all used by the ADSB dashboard in agent mode
- Widen WebSocket init exception guards in app.py from ImportError to
  Exception so any startup failure (e.g. RuntimeError from flask-sock on
  an unsupported WSGI server) is caught instead of propagating

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
James Smith
2026-03-18 20:40:15 +00:00
parent f043baed9f
commit e1b532d48a
3 changed files with 9 additions and 5 deletions

View File

@@ -1167,6 +1167,9 @@ def stream_adsb():
def generate():
last_keepalive = time.time()
# Send immediate keepalive so Werkzeug dev server flushes response
# headers right away (it buffers until first body byte is written).
yield format_sse({'type': 'keepalive'})
try:
while True:

View File

@@ -673,6 +673,7 @@ def stream_all_agents():
def generate() -> Generator[str, None, None]:
last_keepalive = time.time()
keepalive_interval = 30.0
yield format_sse({'type': 'keepalive'})
try:
while True: