fix(explorer): read SSE stream until event and data lines arrive
Some checks failed
Deploy Explorer Live / deploy (push) Failing after 15s

The health check stopped after two non-empty lines and missed the data line that follows event: ping on mission-control streams.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
defiQUG
2026-05-22 18:05:47 -07:00
parent 4b747f0309
commit 0778c18e59

View File

@@ -7,6 +7,7 @@ BASE_URL="${1:-https://explorer.d-bis.org}"
python3 - "$BASE_URL" <<'PY'
import re
import sys
import time
import requests
@@ -158,15 +159,22 @@ try:
if resp.status_code >= 400:
failed = True
else:
lines = []
saw_event = False
saw_data = False
deadline = time.time() + 25
for raw in resp.iter_lines(decode_unicode=True):
if raw:
lines.append(raw)
if len(lines) >= 2:
if raw.startswith("event:"):
saw_event = True
if raw.startswith("data:"):
saw_data = True
if saw_event and saw_data:
break
if not any(line.startswith("event:") for line in lines):
if time.time() > deadline:
break
if not saw_event:
mark_failure(" mission-control stream did not emit an event line")
if not any(line.startswith("data:") for line in lines):
if not saw_data:
mark_failure(" mission-control stream did not emit a data line")
except Exception as exc:
mark_failure(f"ERR /explorer-api/v1/mission-control/stream [{exc}]")