8000 fix(PeerGroup): ignore connections that come in after `disconnect()` … · mappum/webcoin@4cb9a12 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 4cb9a12

Browse files
committed
fix(PeerGroup): ignore connections that come in after disconnect() is called
Fixes errors when a Node is created then immediately closed (e.g. in the tests).
1 parent 78e5c71 commit 4cb9a12

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/peerGroup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ PeerGroup.prototype._connectToTCPPeers = function (cb) {
241241
}
242242

243243
PeerGroup.prototype._onTCPPeerConnect = function (peer) {
244+
if (this.disconnecting) return
244245
peer.getTip = this.getTip
245246
this._onPeerConnect(new Peer(peer))
246247
}
@@ -262,6 +263,7 @@ PeerGroup.prototype._connectToWebPeers = function () {
262263
}
263264

264265
PeerGroup.prototype._onWebPeerConnect = function (conn, incoming) {
266+
if (this.disconnecting) return
265267
var peer = new WebPeer(conn, { incoming: !!incoming, getTip: this.getTip })
266268
peer.connect()
267269
this._onPeerConnect(peer)

0 commit comments

Comments
 (0)
0