From 96684f3f66a4758080d896571af38703c030b156 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Sun, 8 Nov 2026 16:17:02 +0000 Subject: [PATCH] test(ui-react): publish owned-child readiness atomically so an empty file is never read as ready The child's writeFileSync creates the readiness file before writing its bytes, and the parent retried only on ENOENT. A read inside that window returned "" and failed OWNED_CHILD_ACKNOWLEDGED_READINESS at once, long before the 1 s deadline. The child now renames a complete sibling into place, so the file is either absent or complete. Refs #3734 Co-Authored-By: Claude Opus 5.5 --- packages/ui-react/tests/runtime-hook-phases.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/ui-react/tests/runtime-hook-phases.test.ts b/packages/ui-react/tests/runtime-hook-phases.test.ts index 895b79e027..31f5e0ebec 100644 --- a/packages/ui-react/tests/runtime-hook-phases.test.ts +++ b/packages/ui-react/tests/runtime-hook-phases.test.ts @@ -196,7 +196,10 @@ test("owned descendant observation distinguishes live identity, reused identity test("an owned process disappearing after procfs open is stopped without hiding unexpected read errors", async () => { const root = await mkdtemp(join(tmpdir(), "odysseus-procfs-exit-")); const ready = join(root, "ready"); - const child = Bun.spawn([process.execPath, "-e", 'require("node:fs").writeFileSync(process.argv[1],"Odysseus ready");setInterval(()=>{},1000)', ready], { stdin: "ignore", stdout: "pipe", stderr: "pipe" }); + // writeFileSync creates the file before it writes the bytes, so a reader + // can see it empty. Renaming a complete sibling publishes it atomically: + // absent means not ready yet, and present means complete. + const child = Bun.spawn([process.execPath, "-e", 'const fs=require("node:fs"),partial=process.argv[1]+".partial";fs.writeFileSync(partial,"Odysseus ready");fs.renameSync(partial,process.argv[1]);setInterval(()=>{},1000)', ready], { stdin: "ignore", stdout: "pipe", stderr: "pipe" }); let held: Awaited> | undefined; const stdout = new Response(child.stdout).text(); const stderr = new Response(child.stderr).text();