mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-28 05:11:04 +00:00
fix: prevent "The libp2p node is not started yet" when stopping (#138)
This commit is contained in:
parent
c7f20383d9
commit
c88eaf416c
@ -224,8 +224,6 @@ class Node extends EventEmitter {
|
|||||||
* Stop the libp2p node by closing its listeners and open connections
|
* Stop the libp2p node by closing its listeners and open connections
|
||||||
*/
|
*/
|
||||||
stop (callback) {
|
stop (callback) {
|
||||||
this._isStarted = false
|
|
||||||
|
|
||||||
if (this.modules.discovery) {
|
if (this.modules.discovery) {
|
||||||
this.modules.discovery.forEach((discovery) => {
|
this.modules.discovery.forEach((discovery) => {
|
||||||
setImmediate(() => discovery.stop(() => {}))
|
setImmediate(() => discovery.stop(() => {}))
|
||||||
@ -244,7 +242,10 @@ class Node extends EventEmitter {
|
|||||||
this.emit('stop')
|
this.emit('stop')
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
], callback)
|
], (err) => {
|
||||||
|
this._isStarted = false
|
||||||
|
callback(err)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
isStarted () {
|
isStarted () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user