From 6f98b0cc3c0c98cbb8f7113e7cea737b3f30c73c Mon Sep 17 00:00:00 2001 From: Pedro Teixeira Date: Mon, 12 Mar 2018 10:34:55 +0000 Subject: [PATCH] fix: for when peerinfo resolves to undefined --- src/observer.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/observer.js b/src/observer.js index 37e2477..6d8b756 100644 --- a/src/observer.js +++ b/src/observer.js @@ -30,8 +30,10 @@ module.exports = (swtch) => { function willObserve (peerInfo, transport, protocol, direction, bufferLength) { peerInfo.then((pi) => { - const peerId = pi.id.toB58String() - setImmediate(() => observer.emit('message', peerId, transport, protocol, direction, bufferLength)) + if (pi) { + const peerId = pi.id.toB58String() + setImmediate(() => observer.emit('message', peerId, transport, protocol, direction, bufferLength)) + } }) } }