Skip to content

Commit ac95f81

Browse files
committed
refactor: narrow ConnectionClosedEvent param type
1 parent 0f8e6d8 commit ac95f81

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/cmap/connection_pool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
599599
this[kPending]--;
600600
this.emit(
601601
ConnectionPool.CONNECTION_CLOSED,
602-
new ConnectionClosedEvent(this, { id: connectOptions.id } as Connection, 'error')
602+
new ConnectionClosedEvent(this, { id: connectOptions.id, serviceId: undefined }, 'error')
603603
);
604604
callback(err ?? new MongoRuntimeError('Connection creation failed without error'));
605605
return;

src/cmap/connection_pool_events.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent {
106106
serviceId?: ObjectId;
107107

108108
/** @internal */
109-
constructor(pool: ConnectionPool, connection: Connection, reason: string) {
109+
constructor(
110+
pool: ConnectionPool,
111+
connection: Pick<Connection, 'id' | 'serviceId'>,
112+
reason: string
113+
) {
110114
super(pool);
111115
this.connectionId = connection.id;
112116
this.reason = reason || 'unknown';

0 commit comments

Comments
 (0)