From cc9caa168925dc68d4564ba378b47a383a307d8c Mon Sep 17 00:00:00 2001 From: Paul Williams Date: Thu, 16 Jul 2026 13:46:06 -0600 Subject: [PATCH] fix(ci): harden llm-test mock HTTP server against stalled connections macos-latest runner images updated in June and http_native_test.llm began timing out (30s curl timeout) against the mock server while the very next test passed instantly - the signature of the single-threaded HTTPServer being wedged by a stray idle connection. Switch to ThreadingHTTPServer with daemon threads and a 5s per-connection timeout, and replace the blind 0.5s sleep with an active readiness probe that dumps port state diagnostics when the server fails to answer. Test-infrastructure only; no compiler or runtime changes. Co-Authored-By: Claude Fable 5 --- llm-test | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/llm-test b/llm-test index 2d27e96..6b78653 100755 --- a/llm-test +++ b/llm-test @@ -46,10 +46,14 @@ for f in lib/*.llm; do fi done -# Start background mock HTTP server for standard library testing +# Start background mock HTTP server for standard library testing. +# ThreadingHTTPServer + a per-connection timeout so a stray idle connection +# (e.g. a port prober on CI runners) cannot wedge the accept loop and stall +# real requests behind it. python3 -c ' -from http.server import HTTPServer, BaseHTTPRequestHandler +from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler class Handler(BaseHTTPRequestHandler): + timeout = 5 def log_message(self, format, *args): pass def do_GET(self): @@ -64,7 +68,8 @@ class Handler(BaseHTTPRequestHandler): self.send_header("Content-Type", "text/plain") self.end_headers() self.wfile.write(b"Echo: " + body) -server = HTTPServer(("127.0.0.1", 8080), Handler) +server = ThreadingHTTPServer(("127.0.0.1", 8080), Handler) +server.daemon_threads = True server.serve_forever() ' >/dev/null 2>&1 & MOCK_PID=$! @@ -76,8 +81,19 @@ cleanup() { } trap cleanup EXIT -# Wait a brief moment for the server to bind -sleep 0.5 +# Wait until the mock server is actually answering requests (up to 10s) +SERVER_READY=false +for _ in $(seq 1 40); do + if curl -s --max-time 1 http://127.0.0.1:8080/ 2>/dev/null | grep -q "Hello from local mock server"; then + SERVER_READY=true + break + fi + sleep 0.25 +done +if [ "$SERVER_READY" = false ]; then + echo "WARNING: mock HTTP server on 127.0.0.1:8080 is not responding; port state:" + lsof -nP -i :8080 2>/dev/null || true +fi echo "Running llmlang self-hosted tests..." echo "------------------------------------"