mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-04 13:53:34 +00:00
test(sessions): publish concurrency markers atomically (#99212)
This commit is contained in:
committed by
GitHub
parent
a51b06fd4d
commit
a004e18b4b
@@ -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" }));
|
||||
|
||||
Reference in New Issue
Block a user