fix: Stop sync before removing listeners.

This commit is contained in:
Hayden Young 2023-10-11 22:24:05 +01:00
parent a44323851f
commit 3b3f90501c
2 changed files with 1 additions and 5 deletions

View File

@ -255,13 +255,13 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
*/
const stopSync = async () => {
if (started) {
started = false
await queue.onIdle()
ipfs.libp2p.services.pubsub.removeEventListener('subscription-change', handlePeerSubscribed)
ipfs.libp2p.services.pubsub.removeEventListener('message', handleUpdateMessage)
await ipfs.libp2p.unhandle(headsSyncAddress)
await ipfs.libp2p.services.pubsub.unsubscribe(address)
peers.clear()
started = false
}
}

View File

@ -297,10 +297,6 @@ describe('Write Permissions', function () {
await db1.close()
await db2.close()
await new Promise(resolve => {
setTimeout(() => resolve(), 1000)
})
db1 = await orbitdb1.open('write-test', { AccessController: OrbitDBAccessController() })
db2 = await orbitdb2.open(db1.address)