From fbbc6dcfc17dd10d05aa0508a4149177c0a3f912 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 23 Sep 2026 14:38:51 +0200 Subject: [PATCH] Wait for a client before quic-realtime-serve broadcasts Finding 8(b): the serve mode broadcast immediately after printing its ready line, before the harness's dial could reach it, so frames went to an empty peer set and were silently dropped. WaitForFirstConnectionAsync polls ConnectionCount, bounded at 30s so a peer that never gets dialed still exits instead of hanging the interop lane forever. Co-Authored-By: Claude Sonnet 5 --- .../GameCult.Networking.InteropPeer/Program.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/GameCult.Networking.InteropPeer/Program.cs b/tests/GameCult.Networking.InteropPeer/Program.cs index b4c7870e..f07908a9 100644 --- a/tests/GameCult.Networking.InteropPeer/Program.cs +++ b/tests/GameCult.Networking.InteropPeer/Program.cs @@ -1232,6 +1232,12 @@ static async Task QuicRealtimeServeAsync(QuicRealtimeServeConfig config) var endpoint = $"cultmesh-state+quic://127.0.0.1:{server.LocalEndPoint.Port}?cert-sha256={pin}"; WriteJsonLine(new { status = "ready", endpoint }); + // The harness dials only after reading the line above, so broadcasting + // immediately would send to nobody: MsQuic's own send path silently no-ops + // over an empty peer set. Wait for at least one connection first, bounded, + // so a peer that never shows up still exits instead of hanging forever. + await WaitForFirstConnectionAsync(server, TimeSpan.FromSeconds(30)); + var delivery = config.Delivery switch { "reliable-ordered" => CultMeshRealtimeDelivery.ReliableOrdered, @@ -1258,6 +1264,17 @@ static async Task QuicRealtimeServeAsync(QuicRealtimeServeConfig config) } } +static async Task WaitForFirstConnectionAsync(CultMeshQuicRealtimeServer server, TimeSpan timeout) +{ + var deadline = DateTime.UtcNow + timeout; + while (server.ConnectionCount == 0) + { + if (DateTime.UtcNow >= deadline) + throw new TimeoutException($"quic-realtime-serve: no client connected within {timeout}."); + await Task.Delay(20); + } +} + static Task WatchStdinCloseAsync() { return Task.Run(async () =>