@@ -101,10 +101,6 @@ export class Monitor extends TypedEventEmitter<MonitorEvents> {
101
101
/** @internal */
102
102
override component = MongoLoggableComponent . TOPOLOGY ;
103
103
104
- get connection ( ) : Connection | undefined {
105
- return this [ kConnection ] ;
106
- }
107
-
108
104
constructor ( server : Server , options : MonitorOptions ) {
109
105
super ( ) ;
110
106
@@ -264,8 +260,6 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
264
260
awaited
265
261
)
266
262
) ;
267
- monitor [ kConnection ] ?. destroy ( { force : true } ) ;
268
- monitor [ kConnection ] = undefined ;
269
263
270
264
const error = ! ( err instanceof MongoError )
271
265
? new MongoError ( MongoError . buildErrorMessage ( err ) , { cause : err } )
@@ -290,17 +284,23 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
290
284
? monitor . rttPinger . roundTripTime
291
285
: calculateDurationInMs ( start ) ;
292
286
293
- monitor . emit (
287
+ monitor . emitAndLog (
294
288
Server . SERVER_HEARTBEAT_SUCCEEDED ,
295
- new ServerHeartbeatSucceededEvent ( monitor . address , duration , hello , isAwaitable )
289
+ new ServerHeartbeatSucceededEvent (
290
+ monitor [ kServer ] . topology . s . id ,
291
+ monitor . address ,
292
+ duration ,
293
+ hello ,
294
+ isAwaitable
295
+ )
296
296
) ;
297
297
298
298
// If we are using the streaming protocol then we immediately issue another 'started'
299
299
// event, otherwise the "check" is complete and return to the main monitor loop.
300
300
if ( isAwaitable ) {
301
- monitor . emit (
301
+ monitor . emitAndLog (
302
302
Server . SERVER_HEARTBEAT_STARTED ,
303
- new ServerHeartbeatStartedEvent ( monitor . address , true )
303
+ new ServerHeartbeatStartedEvent ( monitor [ kServer ] . topology . s . id , monitor . address , true )
304
304
) ;
305
305
start = now ( ) ;
306
306
} else {
@@ -378,7 +378,7 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
378
378
}
379
379
380
380
monitor . connection = conn ;
381
- monitor . emit (
381
+ monitor . emitAndLog (
382
382
Server . SERVER_HEARTBEAT_SUCCEEDED ,
383
383
new ServerHeartbeatSucceededEvent (
384
384
monitor [ kServer ] . topology . s . id ,
0 commit comments