From a74b8f77eb926dc32162c413f61fe9b4f10f513e Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 10 Jul 2019 09:18:00 +0100 Subject: [PATCH] fix: sometimes no Addrs element is present in the response (#1037) --- src/dht/findprovs.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dht/findprovs.js b/src/dht/findprovs.js index 183adfa93..84c1df8f9 100644 --- a/src/dht/findprovs.js +++ b/src/dht/findprovs.js @@ -44,11 +44,13 @@ module.exports = (send) => { const responses = res.Responses.map((r) => { const peerInfo = new PeerInfo(PeerId.createFromB58String(r.ID)) - r.Addrs.forEach((addr) => { - const ma = multiaddr(addr) + if (r.Addrs) { + r.Addrs.forEach((addr) => { + const ma = multiaddr(addr) - peerInfo.multiaddrs.add(ma) - }) + peerInfo.multiaddrs.add(ma) + }) + } return peerInfo })