From 26368d884513d5083e5b188ff8582f0ea646ff77 Mon Sep 17 00:00:00 2001 From: Qingyang Hu Date: Wed, 13 Sep 2023 10:30:19 -0400 Subject: [PATCH] Use 0 for nil connection. --- x/mongo/driver/topology/server.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/x/mongo/driver/topology/server.go b/x/mongo/driver/topology/server.go index 2b72d3efd8..f544a68131 100644 --- a/x/mongo/driver/topology/server.go +++ b/x/mongo/driver/topology/server.go @@ -799,6 +799,11 @@ func (s *Server) check() (description.Server, error) { // Create a new connection if this is the first check, the connection was closed after an error during the previous // check, or the previous check was cancelled. if s.conn == nil || s.conn.closed() || s.checkWasCancelled() { + connID := "0" + if s.conn != nil { + connID = s.conn.ID() + } + s.publishServerHeartbeatStartedEvent(connID, false) // Create a new connection and add it's handshake RTT as a sample. err = s.setupHeartbeatConnection() duration = time.Since(start)