Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(native-lock): holder fixture publishes its result atomically

garrytana1fbd0648844
diff --git a/test/fixtures/native-lock-process.ts b/test/fixtures/native-lock-process.ts
index edd8050d9e..ba94ca4107 100644
--- a/test/fixtures/native-lock-process.ts
+++ b/test/fixtures/native-lock-process.ts
@@ -1,15 +1,17 @@
-import { existsSync, writeFileSync } from 'node:fs';
+import { existsSync, renameSync, writeFileSync } from 'node:fs';
import { setTimeout as delay } from 'node:timers/promises';
import { tryAcquireNativeLock } from '../../src/core/persistence/native-lock.ts';
const [path, result, start] = process.argv.slice(2);
if (!path || !result) throw new Error('Expected lock and barrier paths');
if (start) {
- writeFileSync(`${result}.ready`, 'ready');
+ writeFileSync(`${result}.ready.tmp`, 'ready');
+ renameSync(`${result}.ready.tmp`, `${result}.ready`);
while (!existsSync(start)) await delay(10);
}
const lock = await tryAcquireNativeLock(path);
-writeFileSync(result, lock ? 'acquired' : 'busy');
+writeFileSync(`${result}.tmp`, lock ? 'acquired' : 'busy');
+renameSync(`${result}.tmp`, result);
if (lock) {
await new Promise<void>(resolve => {
process.stdin.once('data', () => resolve());