(err: Error)
| 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)) { |
no test coverage detected