Skip to content

Commit

Permalink
fix: prevent "The libp2p node is not started yet" when stopping (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgte authored and daviddias committed Dec 15, 2017
1 parent c7f2038 commit c88eaf4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ class Node extends EventEmitter {
* Stop the libp2p node by closing its listeners and open connections
*/
stop (callback) {
this._isStarted = false

if (this.modules.discovery) {
this.modules.discovery.forEach((discovery) => {
setImmediate(() => discovery.stop(() => {}))
Expand All @@ -244,7 +242,10 @@ class Node extends EventEmitter {
this.emit('stop')
cb()
}
], callback)
], (err) => {
this._isStarted = false
callback(err)
})
}

isStarted () {
Expand Down

0 comments on commit c88eaf4

Please sign in to comment.