feat: abort all pending dials on stop

This commit is contained in:
Jacob Heun
2019-12-06 17:45:29 +01:00
parent 0a8f9f3238
commit 754fbc2d0b
4 changed files with 41 additions and 3 deletions

View File

@ -194,8 +194,15 @@ class Libp2p extends EventEmitter {
log('libp2p is stopping')
try {
this.pubsub && await this.pubsub.stop()
this._dht && await this._dht.stop()
await Promise.all([
this.pubsub && this.pubsub.stop(),
this._dht && this._dht.stop()
])
for (const dial of this.dialer.pendingDials.values()) {
dial.abort()
}
await this.transportManager.close()
await this.registrar.close()
} catch (err) {