From 418f7c685553fd6e7749d705a4c4b7db437f86e4 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Tue, 27 Aug 2024 17:28:13 +0200 Subject: [PATCH] chore: add tiemout to findpeers (#569) Signed-off-by: mudler --- pkg/discovery/dht.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/discovery/dht.go b/pkg/discovery/dht.go index 794b4a88..2853ae0b 100644 --- a/pkg/discovery/dht.go +++ b/pkg/discovery/dht.go @@ -234,7 +234,9 @@ func (d *DHT) announceAndConnect(l log.StandardLogger, ctx context.Context, kade // This is like your friend telling you the location to meet you. l.Debug("Searching for other peers...") - peerChan, err := routingDiscovery.FindPeers(ctx, rv) + fCtx, cf := context.WithTimeout(ctx, time.Second*120) + defer cf() + peerChan, err := routingDiscovery.FindPeers(fCtx, rv) if err != nil { return err }