@@ -14,8 +14,8 @@ import {
1414 type EventEmitterWithState ,
1515 makeStateMachine ,
1616 noop ,
17- now ,
18- ns
17+ ns ,
18+ processTimeMS
1919} from '../utils' ;
2020import { ServerType , STATE_CLOSED , STATE_CLOSING } from './common' ;
2121import {
@@ -326,7 +326,7 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
326326 ) ;
327327 // We have not actually sent an outgoing handshake, but when we get the next response we
328328 // want the duration to reflect the time since we last heard from the server
329- start = now ( ) ;
329+ start = processTimeMS ( ) ;
330330 } else {
331331 monitor . rttPinger ?. close ( ) ;
332332 monitor . rttPinger = undefined ;
@@ -360,7 +360,7 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
360360 }
361361
362362 // Record new start time before sending handshake
363- start = now ( ) ;
363+ start = processTimeMS ( ) ;
364364
365365 if ( isAwaitable ) {
366366 awaited = true ;
@@ -383,7 +383,7 @@ function checkServer(monitor: Monitor, callback: Callback<Document | null>) {
383383 const socket = await makeSocket ( monitor . connectOptions ) ;
384384 const connection = makeConnection ( monitor . connectOptions , socket ) ;
385385 // The start time is after socket creation but before the handshake
386- start = now ( ) ;
386+ start = processTimeMS ( ) ;
387387 try {
388388 await performInitialHandshake ( connection , monitor . connectOptions ) ;
389389 return connection ;
@@ -532,7 +532,7 @@ export class RTTPinger {
532532 }
533533
534534 private measureRoundTripTime ( ) {
535- const start = now ( ) ;
535+ const start = processTimeMS ( ) ;
536536
537537 if ( this . closed ) {
538538 return ;
@@ -607,7 +607,7 @@ export class MonitorInterval {
607607 }
608608
609609 wake ( ) {
610- const currentTime = now ( ) ;
610+ const currentTime = processTimeMS ( ) ;
611611 const timeSinceLastCall = currentTime - this . lastExecutionEnded ;
612612
613613 // TODO(NODE-4674): Add error handling and logging to the monitor
@@ -651,7 +651,7 @@ export class MonitorInterval {
651651 }
652652
653653 toJSON ( ) {
654- const currentTime = now ( ) ;
654+ const currentTime = processTimeMS ( ) ;
655655 const timeSinceLastCall = currentTime - this . lastExecutionEnded ;
656656 return {
657657 timerId : this . timerId != null ? 'set' : 'cleared' ,
@@ -684,7 +684,7 @@ export class MonitorInterval {
684684 this . isExecutionInProgress = true ;
685685
686686 this . fn ( ( ) => {
687- this . lastExecutionEnded = now ( ) ;
687+ this . lastExecutionEnded = processTimeMS ( ) ;
688688 this . isExecutionInProgress = false ;
689689 this . _reschedule ( this . heartbeatFrequencyMS ) ;
690690 } ) ;
0 commit comments