Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

test(core): let a heartbeat ping precede the socket's connection_state

Petr Bauch968a6b55b378
diff --git a/core/tests/switch_core/bridges/agent/api/test_connection_socket.py b/core/tests/switch_core/bridges/agent/api/test_connection_socket.py
index 273bab5a4..12976c64e 100644
--- a/core/tests/switch_core/bridges/agent/api/test_connection_socket.py
+++ b/core/tests/switch_core/bridges/agent/api/test_connection_socket.py
@@ -134,7 +134,11 @@ def test_it_opens_like_the_event_stream(
client: TestClient, protocol: _Protocol
) -> None:
with client.websocket_connect(_url(scope="all")) as ws:
+ # The 50 ms heartbeat can beat the stream's first read on a busy
+ # machine, so a ping may come first; nothing else may.
state = ws.receive_json()
+ while state["event"] == "ping":
+ state = ws.receive_json()
assert state["event"] == "connection_state"
assert state["data"]["connection_id"] == "c1"