Skip to content

Commit c086b8c

Browse files
committed
fix: LB leaks connection on client close with expired session error
1 parent 584b4f0 commit c086b8c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/sessions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,11 @@ export function maybeClearPinnedConnection(
523523
const servers = Array.from(topology.s.servers.values());
524524
const loadBalancer = servers[0];
525525

526-
if (options?.error == null || options?.force) {
526+
if (
527+
options?.error == null ||
528+
options?.error?.name === 'MongoExpiredSessionError' ||
529+
options?.force
530+
) {
527531
loadBalancer.pool.checkIn(conn);
528532
session[kPinnedConnection] = undefined;
529533
conn.emit(

0 commit comments

Comments
 (0)