From ff439e450f9953068f464f1ea09f0a3d816818b7 Mon Sep 17 00:00:00 2001 From: Elias Bachaalany Date: Fri, 28 Nov 2025 11:32:50 -0800 Subject: [PATCH] Fix macOS SSE server test connection issues Remove problematic connection test that was causing macOS CI failures: - Removed immediate-cancel connection check (lines 51-67) - Increased server startup wait from 1s to 2s for macOS - Added 100ms delay before SSE thread connection attempts The test connection was canceling immediately (line 61 returned false) which caused connection handling errors on macOS that persisted into the actual test. This left the server in a bad state for subsequent POST and SSE connections. Fixes: # --- tests/server/sse.cpp | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/tests/server/sse.cpp b/tests/server/sse.cpp index fb21046..1d7ef83 100644 --- a/tests/server/sse.cpp +++ b/tests/server/sse.cpp @@ -43,29 +43,12 @@ int main() return 1; } - // Wait for server to be ready - give it more time - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + // Wait for server to be ready - longer delay for macOS compatibility + std::this_thread::sleep_for(std::chrono::milliseconds(2000)); std::cout << "Server started on port " << port << "\n"; - // Test if server is listening: use streaming GET and immediately cancel - // to avoid waiting on an infinite SSE stream. - httplib::Client test_client("127.0.0.1", port); - test_client.set_connection_timeout(std::chrono::seconds(5)); - test_client.set_read_timeout(std::chrono::seconds(5)); - auto test_res = test_client.Get("/sse", - [&](const char*, size_t) - { - // Cancel after first chunk to verify readiness without - // blocking - return false; - }); - if (!test_res) - { - std::cerr << "Test connection failed: " << test_res.error() << "\n"; - std::cerr << "Server may not be ready yet\n"; - } - + // Verify server is running if (!server.running()) { std::cerr << "Server not running after start\n"; @@ -86,6 +69,9 @@ int main() std::thread sse_thread( [&]() { + // Give server a moment to fully initialize before first connection attempt + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + auto sse_receiver = [&](const char* data, size_t len) { sse_connected = true;