From 7b3191c2f85c80c0f5c3ccf0e12893e000d95e78 Mon Sep 17 00:00:00 2001 From: Christopher Modjeska Date: Sun, 5 Jul 2026 01:36:31 -0400 Subject: [PATCH] fix: ECOMPROMISED lockfile crash and release errors The onCompromised handler no longer throws, preventing process crashes under disk I/O pressure. Lock release errors in the withLocks finally block are caught silently. --- src/fs/locked-file-system.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/fs/locked-file-system.ts b/src/fs/locked-file-system.ts index bd143ce351..7df268cd82 100644 --- a/src/fs/locked-file-system.ts +++ b/src/fs/locked-file-system.ts @@ -50,10 +50,10 @@ function createLockOptions(request: LockRequest, lockfilePath: string): LockOpti retries: request.retries ?? DEFAULT_LOCK_RETRIES, realpath: false, lockfilePath, + // Don't crash on ECOMPROMISED — the lock is silently released instead. + // This prevents process crashes under disk I/O pressure. + onCompromised: request.onCompromised ?? (() => {}), }; - if (typeof request.onCompromised === "function") { - options.onCompromised = request.onCompromised; - } return options; } @@ -108,7 +108,11 @@ export class LockedFileSystem { return await operation(); } finally { for (const release of releases.reverse()) { - await release(); + try { + await release(); + } catch { + /* lock already released (e.g. ECOMPROMISED) */ + } } } }