fix: recover from malformed instance lock files

Co-authored-by: Haze <hazeone@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-03-18 15:19:45 +00:00
committed by Haze
parent 5a4c63f7f3
commit 6d79a4f881
2 changed files with 19 additions and 1 deletions

View File

@@ -77,4 +77,20 @@ describe('process instance file lock', () => {
expect(readFileSync(lockPath, 'utf8')).toBe('5555');
lock.release();
});
it('replaces malformed lock file content', () => {
const userDataDir = createTempDir();
const lockPath = join(userDataDir, 'clawx.instance.lock');
writeFileSync(lockPath, 'not-a-pid', 'utf8');
const lock = acquireProcessInstanceFileLock({
userDataDir,
lockName: 'clawx',
pid: 6666,
});
expect(lock.acquired).toBe(true);
expect(readFileSync(lockPath, 'utf8')).toBe('6666');
lock.release();
});
});