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 <noreply@anthropic.com>
This commit is contained in:
parent
047c55c453
commit
fbbc6dcfc1
1 changed files with 17 additions and 0 deletions
|
|
@ -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 () =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue