Skip to content

Commit 894e3cc

Browse files
dirkmcvasco-santos
authored andcommitted
fix: crash when disconnect happens during dial (#65)
1 parent 54632b3 commit 894e3cc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ class FloodSub extends BaseProtocol {
4646
if (err) return callback(err)
4747
const idB58Str = peerInfo.id.toB58String()
4848
const peer = this.peers.get(idB58Str)
49-
// Immediately send my own subscriptions to the newly established conn
50-
peer.sendSubscriptions(this.subscriptions)
49+
if (peer && peer.isWritable) {
50+
// Immediately send my own subscriptions to the newly established conn
51+
peer.sendSubscriptions(this.subscriptions)
52+
}
5153
setImmediate(() => callback())
5254
})
5355
}

0 commit comments

Comments
 (0)