From 4848313cb33047ac93e07f45e4e8b0f1cb4cc637 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Wed, 23 Sep 2020 11:19:59 +0200 Subject: [PATCH] chore: _isStarted is false when stop starts --- src/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 6fd76504..c48b26b3 100644 --- a/src/index.js +++ b/src/index.js @@ -247,6 +247,7 @@ class Libp2p extends EventEmitter { log('libp2p is stopping') try { + this._isStarted = false for (const service of this._discovery.values()) { service.removeListener('peer', this._onDiscoveryPeer) } @@ -258,7 +259,6 @@ class Libp2p extends EventEmitter { await this.peerStore.stop() await this.connectionManager.stop() - ping.unmount(this) await Promise.all([ this.pubsub && this.pubsub.stop(), this._dht && this._dht.stop(), @@ -267,6 +267,8 @@ class Libp2p extends EventEmitter { await this.transportManager.close() + ping.unmount(this) + this.dialer.destroy() } catch (err) { if (err) { @@ -274,7 +276,6 @@ class Libp2p extends EventEmitter { this.emit('error', err) } } - this._isStarted = false log('libp2p has stopped') }