diff --git a/src/features/team-mode/team-state-store/locks.ts b/src/features/team-mode/team-state-store/locks.ts index 0fca98494..2f7a4d4a0 100644 --- a/src/features/team-mode/team-state-store/locks.ts +++ b/src/features/team-mode/team-state-store/locks.ts @@ -1,6 +1,8 @@ import { randomUUID } from "node:crypto" import { open, readFile, rename, rm, unlink, writeFile } from "node:fs/promises" +import { tolerantFsync } from "../../../shared/tolerant-fsync" + type LockOptions = { staleAfterMs?: number ownerTag?: string @@ -51,7 +53,7 @@ async function acquireLock(lockPath: string, ownerTag: string, staleAfterMs: num const fileHandle = await open(lockPath, "wx") try { await fileHandle.writeFile(buildOwnerContent(ownerTag)) - await fileHandle.sync() + await tolerantFsync(fileHandle, `acquireLock:${lockPath}`) } finally { await fileHandle.close() } @@ -116,7 +118,7 @@ export async function atomicWrite( await writeFile(tmpPath, content) const fileHandle = await open(tmpPath, "r") try { - await fileHandle.sync() + await tolerantFsync(fileHandle, `atomicWrite:${filePath}`) } finally { await fileHandle.close() }