diff --git a/internal/p2p/router.go b/internal/p2p/router.go index 56558a80f..55377169c 100644 --- a/internal/p2p/router.go +++ b/internal/p2p/router.go @@ -427,8 +427,10 @@ func (r *Router) routeChannel( ) { for { select { - case envelope := <-outCh: - if envelope.IsZero() { + case envelope, ok := <-outCh: + if !ok { + return + } else if envelope.IsZero() { continue } // Mark the envelope with the channel ID to allow sendPeer() to pass @@ -507,7 +509,10 @@ func (r *Router) routeChannel( } } - case peerError := <-errCh: + case peerError, ok := <-errCh: + if !ok { + return + } maxPeerCapacity := r.peerManager.HasMaxPeerCapacity() r.logger.Error("peer error", "peer", peerError.NodeID,