Skip to content

Commit 4a28129

Browse files
authored
Fix macOS SSE server test connection issues
Fixes macOS CI test failures in fastmcpp_sse_server test. Issue: Connection readiness check immediately canceled connections, leaving server in bad state on macOS. Solution: - Removed flaky connection test (lines 51-67, -20 lines) - Increased server startup wait (1s → 2s for macOS compatibility) - Added 100ms delay before SSE thread connection Result: macOS Debug/Release tests now passing ✅ Note: Windows failures are pre-existing heap exhaustion issue (C1060), addressed separately in PR #13.
1 parent 43e5e64 commit 4a28129

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

tests/server/sse.cpp

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,12 @@ int main()
4343
return 1;
4444
}
4545

46-
// Wait for server to be ready - give it more time
47-
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
46+
// Wait for server to be ready - longer delay for macOS compatibility
47+
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
4848

4949
std::cout << "Server started on port " << port << "\n";
5050

51-
// Test if server is listening: use streaming GET and immediately cancel
52-
// to avoid waiting on an infinite SSE stream.
53-
httplib::Client test_client("127.0.0.1", port);
54-
test_client.set_connection_timeout(std::chrono::seconds(5));
55-
test_client.set_read_timeout(std::chrono::seconds(5));
56-
auto test_res = test_client.Get("/sse",
57-
[&](const char*, size_t)
58-
{
59-
// Cancel after first chunk to verify readiness without
60-
// blocking
61-
return false;
62-
});
63-
if (!test_res)
64-
{
65-
std::cerr << "Test connection failed: " << test_res.error() << "\n";
66-
std::cerr << "Server may not be ready yet\n";
67-
}
68-
51+
// Verify server is running
6952
if (!server.running())
7053
{
7154
std::cerr << "Server not running after start\n";
@@ -86,6 +69,9 @@ int main()
8669
std::thread sse_thread(
8770
[&]()
8871
{
72+
// Give server a moment to fully initialize before first connection attempt
73+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
74+
8975
auto sse_receiver = [&](const char* data, size_t len)
9076
{
9177
sse_connected = true;

0 commit comments

Comments
 (0)