From 2a1b2b7fba9c93935c3d33144d52a2809d3d83cf Mon Sep 17 00:00:00 2001 From: Pedro Teixeira Date: Tue, 12 Dec 2017 10:54:36 +0000 Subject: [PATCH] fix: handling not connecting by emitting disconnect event. Should fix #2 --- src/connection.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/connection.js b/src/connection.js index 67ea35c..e6a6f1f 100644 --- a/src/connection.js +++ b/src/connection.js @@ -43,13 +43,13 @@ module.exports = class Connection extends EventEmitter { } if (!peerAddresses.length) { - this.emit('error', new Error('could not connect to ' + this._id)) + this.emit('disconnect') return // early } this._ipfs._libp2pNode.dial(peerAddresses[0], PROTOCOL, (err, conn) => { if (err) { - this.emit('error', err) + this.emit('disconnect') return // early } this._connecting = false