From 41ee52d2efcb7e7b5782107045935e55e5e6093c Mon Sep 17 00:00:00 2001 From: maradini77 <140460067+maradini77@users.noreply.github.com> Date: Fri, 10 Oct 2025 11:14:23 +0200 Subject: [PATCH] Update handshake.go --- beacon-chain/p2p/handshake.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beacon-chain/p2p/handshake.go b/beacon-chain/p2p/handshake.go index 0b7f66c14a20..096f337555ac 100644 --- a/beacon-chain/p2p/handshake.go +++ b/beacon-chain/p2p/handshake.go @@ -57,7 +57,10 @@ func (s *Service) disconnectFromPeerOnError( // Only attempt a goodbye if we are still connected to the peer. if s.host.Network().Connectedness(remotePeerID) == network.Connected { - if err := goodByeFunc(context.TODO(), remotePeerID); err != nil { + // Use a bounded context to avoid blocking on goodbye in unstable networks. + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + if err := goodByeFunc(ctx, remotePeerID); err != nil { log.WithError(err).Error("Unable to disconnect from peer") } }