Skip to content

Commit b139f17

Browse files
committed
fix(NODE-5106): MongoClient connect release lock if promise throw
1 parent b4bb033 commit b139f17

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/mongo_client.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,13 @@ export class MongoClient extends TypedEventEmitter<MongoClientEvents> {
459459
return this;
460460
})();
461461

462-
await this.connectionLock;
463-
// release
464-
this.connectionLock = undefined;
462+
try {
463+
await this.connectionLock;
464+
} finally {
465+
// release
466+
this.connectionLock = undefined;
467+
}
468+
465469
return this;
466470
}
467471

0 commit comments

Comments
 (0)