Skip to content

Commit 2d9b8f9

Browse files
committed
fix(desktop): narrow the lock check into a type guard
`atomic-write.ts(48,32): Type 'unknown' is not assignable to type 'Error | undefined'` under `bun run typecheck` in packages/desktop: the retry loop returns the caught error after the retries run out, but a plain boolean helper does not narrow the catch variable. Making isLockedError a `cause is NodeJS.ErrnoException` guard narrows the caught value past the early throw. Tests, lint and formatting are unchanged.
1 parent 7257166 commit 2d9b8f9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎packages/desktop/src/main/storage/atomic-write.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const retryDelayMs = 15
1515
// A sharing violation is the one failure a later attempt can survive; nothing else clears by
1616
// waiting. The three codes are what Node reports for it, depending on how the holder opened the
1717
// file: EPERM for a denied replacement, EBUSY for a denied open.
18-
function isLockedError(cause: unknown) {
18+
function isLockedError(cause: unknown): cause is NodeJS.ErrnoException {
1919
if (!(cause instanceof Error) || !("code" in cause)) return false
2020

2121
return cause.code === "EPERM" || cause.code === "EACCES" || cause.code === "EBUSY"

0 commit comments

Comments
 (0)