Skip to content

Commit

Permalink
refactor: narrow ConnectionClosedEvent param type
Browse files Browse the repository at this point in the history
  • Loading branch information
dariakp committed Sep 28, 2022
1 parent 0f8e6d8 commit ac95f81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cmap/connection_pool.ts
Expand Up @@ -599,7 +599,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
this[kPending]--;
this.emit(
ConnectionPool.CONNECTION_CLOSED,
new ConnectionClosedEvent(this, { id: connectOptions.id } as Connection, 'error')
new ConnectionClosedEvent(this, { id: connectOptions.id, serviceId: undefined }, 'error')
);
callback(err ?? new MongoRuntimeError('Connection creation failed without error'));
return;
Expand Down
6 changes: 5 additions & 1 deletion src/cmap/connection_pool_events.ts
Expand Up @@ -106,7 +106,11 @@ export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent {
serviceId?: ObjectId;

/** @internal */
constructor(pool: ConnectionPool, connection: Connection, reason: string) {
constructor(
pool: ConnectionPool,
connection: Pick<Connection, 'id' | 'serviceId'>,
reason: string
) {
super(pool);
this.connectionId = connection.id;
this.reason = reason || 'unknown';
Expand Down

0 comments on commit ac95f81

Please sign in to comment.