@peerbit/pubsub 5.4.11 → 5.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peerbit/pubsub",
3
- "version": "5.4.11",
3
+ "version": "5.4.12",
4
4
  "description": "Direct streaming for libp2p",
5
5
  "type": "module",
6
6
  "types": "./dist/src/index.d.ts",
@@ -87,8 +87,8 @@
87
87
  "uint8arrays": "^5.1.0",
88
88
  "@peerbit/any-store-interface": "1.1.4",
89
89
  "@peerbit/crypto": "3.1.6",
90
- "@peerbit/pubsub-interface": "5.2.2",
91
90
  "@peerbit/logger": "2.0.2",
91
+ "@peerbit/pubsub-interface": "5.2.2",
92
92
  "@peerbit/stream": "5.2.4",
93
93
  "@peerbit/stream-interface": "6.0.16",
94
94
  "@peerbit/time": "3.0.1"
@@ -1464,6 +1464,11 @@ export class FanoutTree extends DirectStream<FanoutTreeEvents> {
1464
1464
  this.topicRootControlPlane =
1465
1465
  topicRootControlPlane ?? new TopicRootControlPlane();
1466
1466
 
1467
+ this.registerUnderlayPeerDisconnectHandler();
1468
+ }
1469
+
1470
+ private registerUnderlayPeerDisconnectHandler() {
1471
+ if (this.underlayPeerDisconnectHandler) return;
1467
1472
  const onPeerDisconnect = (ev: any) => {
1468
1473
  const peerId = ev?.detail;
1469
1474
  if (!peerId) return;
@@ -1482,6 +1487,15 @@ export class FanoutTree extends DirectStream<FanoutTreeEvents> {
1482
1487
  );
1483
1488
  }
1484
1489
 
1490
+ public override async start() {
1491
+ await super.start();
1492
+ // stop() removes the listener, so a restarted instance must add it again
1493
+ // (but not while a stop that raced this start is still tearing down).
1494
+ if (this.started && !this.stopping) {
1495
+ this.registerUnderlayPeerDisconnectHandler();
1496
+ }
1497
+ }
1498
+
1485
1499
  private createLoopCloseController(): AbortController {
1486
1500
  const controller = new AbortController();
1487
1501
  const stopSignal = this.closeController.signal;