mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-06 06:06:38 +00:00
fix: Stop sync before removing listeners.
This commit is contained in:
parent
a44323851f
commit
3b3f90501c
@ -255,13 +255,13 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
|
|||||||
*/
|
*/
|
||||||
const stopSync = async () => {
|
const stopSync = async () => {
|
||||||
if (started) {
|
if (started) {
|
||||||
|
started = false
|
||||||
await queue.onIdle()
|
await queue.onIdle()
|
||||||
ipfs.libp2p.services.pubsub.removeEventListener('subscription-change', handlePeerSubscribed)
|
ipfs.libp2p.services.pubsub.removeEventListener('subscription-change', handlePeerSubscribed)
|
||||||
ipfs.libp2p.services.pubsub.removeEventListener('message', handleUpdateMessage)
|
ipfs.libp2p.services.pubsub.removeEventListener('message', handleUpdateMessage)
|
||||||
await ipfs.libp2p.unhandle(headsSyncAddress)
|
await ipfs.libp2p.unhandle(headsSyncAddress)
|
||||||
await ipfs.libp2p.services.pubsub.unsubscribe(address)
|
await ipfs.libp2p.services.pubsub.unsubscribe(address)
|
||||||
peers.clear()
|
peers.clear()
|
||||||
started = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,10 +297,6 @@ describe('Write Permissions', function () {
|
|||||||
await db1.close()
|
await db1.close()
|
||||||
await db2.close()
|
await db2.close()
|
||||||
|
|
||||||
await new Promise(resolve => {
|
|
||||||
setTimeout(() => resolve(), 1000)
|
|
||||||
})
|
|
||||||
|
|
||||||
db1 = await orbitdb1.open('write-test', { AccessController: OrbitDBAccessController() })
|
db1 = await orbitdb1.open('write-test', { AccessController: OrbitDBAccessController() })
|
||||||
db2 = await orbitdb2.open(db1.address)
|
db2 = await orbitdb2.open(db1.address)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user