Skip to content

Commit

Permalink
Fixed a bug where errors thrown from performLockedOperation would c…
Browse files Browse the repository at this point in the history
…ause a 'lock leak'!
  • Loading branch information
T99 committed Sep 14, 2021
1 parent 380d4ab commit df6b9ad
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions ts/semaphore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,19 @@ export class Semaphore {

let lock: SemaphoreLock = await this.getLock();

let result: T = await operation();

lock.release();

return result;
try {

return await operation();

} catch (error: any) {

throw error;

} finally {

lock.release();

}

}

Expand Down

0 comments on commit df6b9ad

Please sign in to comment.