Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 74aed40

Browse files
committed
Fix canceling subscription
1 parent 3b365f7 commit 74aed40

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/core/components/pubsub.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ module.exports = function pubsub (self) {
4747

4848
// There is no explicit unsubscribe; subscriptions have a cancel event
4949
stream.cancel = promisify((cb) => {
50+
// Remove the event listener
51+
self._pubsub.removeAllListeners(topic)
52+
// Make sure floodsub knows we've unsubscribed
5053
self._pubsub.unsubscribe(topic)
54+
// Remove the subscription from pubsub's internal state
5155
removeSubscription(topic, cb)
5256
})
5357

0 commit comments

Comments
 (0)