mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 02:41:07 +00:00
test: harden threaded channel follow-ups
This commit is contained in:
@@ -40,6 +40,14 @@ function releaseAllLocksSync(): void {
|
||||
}
|
||||
}
|
||||
|
||||
async function drainAllLocks(): Promise<void> {
|
||||
for (const [normalizedFile, held] of Array.from(HELD_LOCKS.entries())) {
|
||||
HELD_LOCKS.delete(normalizedFile);
|
||||
await held.handle.close().catch(() => undefined);
|
||||
await fs.rm(held.lockPath, { force: true }).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
function rmLockPathSync(lockPath: string): void {
|
||||
try {
|
||||
fsSync.rmSync(lockPath, { force: true });
|
||||
@@ -133,6 +141,10 @@ export function resetFileLockStateForTest(): void {
|
||||
releaseAllLocksSync();
|
||||
}
|
||||
|
||||
export async function drainFileLockStateForTest(): Promise<void> {
|
||||
await drainAllLocks();
|
||||
}
|
||||
|
||||
/** Acquire a re-entrant process-local file lock backed by a `.lock` sidecar file. */
|
||||
export async function acquireFileLock(
|
||||
filePath: string,
|
||||
|
||||
Reference in New Issue
Block a user