Skip to content

Commit ac7fd52

Browse files
authored
fix: sync leave() function (#378)
* fix: sync leave() function * fix: delete mesh at the end of leave() function
1 parent 7a20b0c commit ac7fd52

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,9 +1758,7 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements PubSub<G
17581758
}
17591759
}
17601760

1761-
this.leave(topic).catch((err) => {
1762-
this.log(err)
1763-
})
1761+
this.leave(topic)
17641762
}
17651763

17661764
/**
@@ -1834,7 +1832,7 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements PubSub<G
18341832
/**
18351833
* Leave topic
18361834
*/
1837-
private async leave(topic: TopicStr): Promise<void> {
1835+
private leave(topic: TopicStr): void {
18381836
if (this.status.code !== GossipStatusCode.started) {
18391837
throw new Error('Gossipsub has not started')
18401838
}
@@ -1845,12 +1843,14 @@ export class GossipSub extends EventEmitter<GossipsubEvents> implements PubSub<G
18451843
// Send PRUNE to mesh peers
18461844
const meshPeers = this.mesh.get(topic)
18471845
if (meshPeers) {
1848-
await Promise.all(
1846+
Promise.all(
18491847
Array.from(meshPeers).map(async (id) => {
18501848
this.log('LEAVE: Remove mesh link to %s in %s', id, topic)
18511849
return await this.sendPrune(id, topic)
18521850
})
1853-
)
1851+
).catch((err) => {
1852+
this.log('Error sending prunes to mesh peers', err)
1853+
})
18541854
this.mesh.delete(topic)
18551855
}
18561856
}

0 commit comments

Comments
 (0)