From 499315afc571c4e841d3e69c4f828939f8dc569a Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 23 Sep 2026 14:38:58 +0200 Subject: [PATCH] Keep stdin piped for the QUIC interop peer, and close it at teardown Finding 8(a): every spawnServeProcess call used stdio ["ignore", ...], which hands the C# quic-realtime-serve peer an already-closed stdin. Its own WatchStdinCloseAsync (Program.cs:1261-1269) treats that as EOF and tears the serve loop down at once, before it can send anything. spawnServeProcess gains an opt-in `stdin: "pipe"` (default stays "ignore" for every other serve mode, which never reads stdin), used only by the "CultMesh QUIC realtime" test; its teardown ends that pipe explicitly before killing the process. Co-Authored-By: Claude Sonnet 5 --- .../test/interop/cultnet-interop.test.ts | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/cultnet-ts/test/interop/cultnet-interop.test.ts b/packages/cultnet-ts/test/interop/cultnet-interop.test.ts index edc3a144..3d9fd257 100644 --- a/packages/cultnet-ts/test/interop/cultnet-interop.test.ts +++ b/packages/cultnet-ts/test/interop/cultnet-interop.test.ts @@ -7,7 +7,7 @@ import { existsSync, rmSync } from "node:fs"; import { connect as connectTcp, createServer } from "node:net"; import { homedir, networkInterfaces, tmpdir } from "node:os"; import { delimiter, dirname, join, resolve } from "node:path"; -import type { Readable } from "node:stream"; +import type { Readable, Writable } from "node:stream"; import { test } from "node:test"; import { setTimeout as delay } from "node:timers/promises"; import { promisify } from "node:util"; @@ -407,6 +407,10 @@ test("CultMesh QUIC realtime: C# managed provider and TypeScript consumer", asyn const servers: RunningServeProcess[] = []; t.after(async () => { for (const server of servers) { + // The C# quic-realtime-serve peer watches stdin for EOF as its own + // shutdown signal; end it explicitly before killing so a lingering pipe + // never masks whether the process exited on its own. + server.child.stdin?.end(); server.child.kill(); } await delay(processCleanupTimeoutMs); @@ -423,6 +427,7 @@ test("CultMesh QUIC realtime: C# managed provider and TypeScript consumer", asyn "--interval-ms", "50", ], cwd: cultLibRoot, + stdin: "pipe", })); const ready = (await servers[servers.length - 1].ready) as { status: string; endpoint: string }; assert.equal(ready.status, "ready"); @@ -2541,11 +2546,21 @@ interface ServeCommand { args: string[]; cwd: string; env?: NodeJS.ProcessEnv; + /** + * Defaults to "ignore" (every existing serve mode's stdin is unused, so it + * is closed at spawn). "pipe" keeps stdin open until the caller ends it: the + * C# `quic-realtime-serve` mode watches stdin for EOF as its own shutdown + * signal (`WatchStdinCloseAsync`, `Program.cs:1261-1269`), so spawning it + * with "ignore" hands it an already-closed stdin and it tears down before + * sending anything. Only that mode should ask for "pipe"; changing the + * default would affect every other serve process spawned here. + */ + stdin?: "ignore" | "pipe"; } interface RunningServeProcess { name: string; - child: ChildProcessByStdio; + child: ChildProcessByStdio; ready: Promise; stderr: string[]; } @@ -2554,7 +2569,7 @@ async function spawnServeProcess(name: string, command: ServeCommand): Promise