Skip to content

Commit

Permalink
handle error
Browse files Browse the repository at this point in the history
  • Loading branch information
mabaasit committed Oct 31, 2024
1 parent d2e9cba commit 01b2f94
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/compass-user-data/src/user-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ export class UserData<T extends z.Schema> {
let data: string;
let stats: Stats;
let handle: fs.FileHandle | undefined = undefined;
const release = await this.semaphore.waitForRelease();
let release: (() => void) | undefined = undefined;
try {
release = await this.semaphore.waitForRelease();
handle = await fs.open(absolutePath, 'r');
[stats, data] = await Promise.all([
handle.stat(),
Expand All @@ -142,7 +143,7 @@ export class UserData<T extends z.Schema> {
throw error;
} finally {
await handle?.close();
release();
release?.();
}

try {
Expand Down

0 comments on commit 01b2f94

Please sign in to comment.