Skip to content

Commit 01b2f94

Browse files
committed
handle error
1 parent d2e9cba commit 01b2f94

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/compass-user-data/src/user-data.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ export class UserData<T extends z.Schema> {
124124
let data: string;
125125
let stats: Stats;
126126
let handle: fs.FileHandle | undefined = undefined;
127-
const release = await this.semaphore.waitForRelease();
127+
let release: (() => void) | undefined = undefined;
128128
try {
129+
release = await this.semaphore.waitForRelease();
129130
handle = await fs.open(absolutePath, 'r');
130131
[stats, data] = await Promise.all([
131132
handle.stat(),
@@ -142,7 +143,7 @@ export class UserData<T extends z.Schema> {
142143
throw error;
143144
} finally {
144145
await handle?.close();
145-
release();
146+
release?.();
146147
}
147148

148149
try {

0 commit comments

Comments
 (0)