Skip to content

Commit 0c88a12

Browse files
committed
GODRIVER-1695 Add timeout to IsMaster call in heartbeat
1 parent 750fe7d commit 0c88a12

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

x/mongo/driver/topology/server.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,11 @@ func (s *Server) heartbeat(conn *connection) (description.Server, *connection) {
502502
NewIsMaster().
503503
ClusterClock(s.cfg.clock).
504504
Deployment(driver.SingleConnectionDeployment{initConnection{conn}})
505-
err = op.Execute(ctx)
505+
506+
timeoutCtx, cancel := context.WithTimeout(ctx, s.cfg.heartbeatTimeout)
507+
defer cancel()
508+
509+
err = op.Execute(timeoutCtx)
506510
if err == nil {
507511
tmpDesc := op.Result(s.address)
508512
descPtr = &tmpDesc

0 commit comments

Comments
 (0)