MCPcopy
hub / github.com/mongodb/node-mongodb-native / onHeartbeatFailed

Function onHeartbeatFailed

src/sdam/monitor.ts:273–293  ·  view source on GitHub ↗
(err: Error)

Source from the content-addressed store, hash-verified

271 );
272
273 function onHeartbeatFailed(err: Error) {
274 monitor.connection?.destroy();
275 monitor.connection = null;
276 monitor.emitAndLogHeartbeat(
277 Server.SERVER_HEARTBEAT_FAILED,
278 monitor.server.topology.s.id,
279 undefined,
280 new ServerHeartbeatFailedEvent(monitor.address, calculateDurationInMs(start), err, awaited)
281 );
282
283 const error = !(err instanceof MongoError)
284 ? new MongoError(MongoError.buildErrorMessage(err), { cause: err })
285 : err;
286 error.addErrorLabel(MongoErrorLabel.ResetPool);
287 if (error instanceof MongoNetworkTimeoutError) {
288 error.addErrorLabel(MongoErrorLabel.InterruptInUseConnections);
289 }
290
291 monitor.emit('resetServer', error);
292 callback(err);
293 }
294
295 function onHeartbeatSucceeded(hello: Document) {
296 if (!('isWritablePrimary' in hello)) {

Callers 1

checkServerFunction · 0.85

Calls 7

calculateDurationInMsFunction · 0.90
emitAndLogHeartbeatMethod · 0.80
buildErrorMessageMethod · 0.80
addErrorLabelMethod · 0.80
emitMethod · 0.65
callbackFunction · 0.50
destroyMethod · 0.45

Tested by

no test coverage detected