From 0778c18e5915b4093d0ddd5deb21e3399e9b16be Mon Sep 17 00:00:00 2001 From: defiQUG Date: Fri, 22 May 2026 18:05:47 -0700 Subject: [PATCH] fix(explorer): read SSE stream until event and data lines arrive 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 --- scripts/check-explorer-health.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/check-explorer-health.sh b/scripts/check-explorer-health.sh index 9c7fe2f..dfe40d9 100755 --- a/scripts/check-explorer-health.sh +++ b/scripts/check-explorer-health.sh @@ -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}]")