From a004e18b4bbd30b784239741e07fdcaf569968f2 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 2 Jul 2026 12:30:45 -0700 Subject: [PATCH] test(sessions): publish concurrency markers atomically (#99212) --- .../session-accessor.reply-init-concurrency.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/config/sessions/session-accessor.reply-init-concurrency.test.ts b/src/config/sessions/session-accessor.reply-init-concurrency.test.ts index 8a00934bc869..25de1d5339b5 100644 --- a/src/config/sessions/session-accessor.reply-init-concurrency.test.ts +++ b/src/config/sessions/session-accessor.reply-init-concurrency.test.ts @@ -84,7 +84,10 @@ async function waitForFile(filePath) { } async function writeJsonFile(filePath, value) { - await fs.writeFile(filePath, \`\${JSON.stringify(value, null, 2)}\\n\`, "utf8"); + // The parent treats file existence as the readiness signal, so publish atomically. + const tempPath = filePath + "." + process.pid + ".tmp"; + await fs.writeFile(tempPath, \`\${JSON.stringify(value, null, 2)}\\n\`, "utf8"); + await fs.rename(tempPath, filePath); } const storePath = process.env.REPLY_INIT_STORE_PATH; @@ -192,7 +195,6 @@ describe("reply session initialization concurrency", () => { stdio: ["ignore", "pipe", "pipe"], }, ); - await waitForFile(readyPath); const snapshot = await readJsonFile<{ currentEntry?: unknown; revision: string }>(readyPath); expect(snapshot.revision).toBe(JSON.stringify({ sessionId: "existing-session" }));