@peerbit/pubsub 5.4.7 → 5.4.9
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/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +66 -28
- package/dist/src/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +108 -30
package/dist/src/index.d.ts
CHANGED
|
@@ -138,6 +138,7 @@ export declare class TopicControlPlane extends DirectStream<PubSubEvents> implem
|
|
|
138
138
|
private readonly nativeTopicControl?;
|
|
139
139
|
private debounceSubscribeAggregator;
|
|
140
140
|
private debounceUnsubscribeAggregator;
|
|
141
|
+
private readonly subscriptionDebounceDelay;
|
|
141
142
|
private readonly shardCount;
|
|
142
143
|
private readonly shardTopicPrefix;
|
|
143
144
|
private readonly topicRootCandidateClaimData;
|
|
@@ -180,6 +181,7 @@ export declare class TopicControlPlane extends DirectStream<PubSubEvents> implem
|
|
|
180
181
|
private pendingTopicRootQueries;
|
|
181
182
|
private nextTopicRootQueryId;
|
|
182
183
|
constructor(components: TopicControlPlaneComponents, props?: TopicControlPlaneOptions);
|
|
184
|
+
private createSubscriptionAggregators;
|
|
183
185
|
/**
|
|
184
186
|
* Return a detached, read-only snapshot of effective runtime settings.
|
|
185
187
|
*/
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EACN,aAAa,EAGb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAIN,KAAK,MAAM,EAEX,KAAK,YAAY,EAIjB,gBAAgB,EAehB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,YAAY,EACZ,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,WAAW,E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,CAAA;KAAE,GAC1C,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IA+C3B,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAWhD,iBAAiB,CAAC,aAAa,EAAE,MAAM;IA2BvD,OAAO,CAAC,wBAAwB;IA8BhC,OAAO,CAAC,gCAAgC;IAoCxC,OAAO,CAAC,mBAAmB;IA8B3B,OAAO,CAAC,yBAAyB;IA0DjC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,2BAA2B;IAcnC;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;YAqDjB,wBAAwB;YAoCxB,4BAA4B;YA4C5B,0BAA0B;YAiL1B,yBAAyB;IAoNjB,aAAa,CAClC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM;CAsFnB;AAED,eAAO,MAAM,kBAAkB,GAC9B,QAAQ;IAAE,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EACxC,aACG,MAAM,GACN,MAAM,EAAE,GACR;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GACxB;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,EAAE,GAC1B,MAAM,GACN,MAAM,EAAE,EACX,OAAO,MAAM,EACb,UAAU;IAAE,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,kBAiKpD,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -193,6 +193,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
193
193
|
nativeTopicControl;
|
|
194
194
|
debounceSubscribeAggregator;
|
|
195
195
|
debounceUnsubscribeAggregator;
|
|
196
|
+
subscriptionDebounceDelay;
|
|
196
197
|
shardCount;
|
|
197
198
|
shardTopicPrefix;
|
|
198
199
|
topicRootCandidateClaimData;
|
|
@@ -309,10 +310,15 @@ export class TopicControlPlane extends DirectStream {
|
|
|
309
310
|
this.fanoutPublishMaxEphemeralChannels = Math.max(0, Math.floor(requestedMaxEphemeral));
|
|
310
311
|
const requestedSubscriberCacheMaxEntries = props?.subscriberCacheMaxEntries ?? SUBSCRIBER_CACHE_DEFAULT_MAX_ENTRIES;
|
|
311
312
|
this.subscriberCacheMaxEntries = Math.min(SUBSCRIBER_CACHE_MAX_ENTRIES_HARD_CAP, Math.max(1, Math.floor(requestedSubscriberCacheMaxEntries)));
|
|
312
|
-
this.
|
|
313
|
+
this.subscriptionDebounceDelay = props?.subscriptionDebounceDelay ?? 50;
|
|
314
|
+
this.createSubscriptionAggregators();
|
|
315
|
+
}
|
|
316
|
+
createSubscriptionAggregators() {
|
|
317
|
+
const lifecycleRevision = this.topicControlPlaneLifecycleRevision;
|
|
318
|
+
this.debounceSubscribeAggregator = debouncedAccumulatorSetCounter((set) => this._subscribe([...set.values()], lifecycleRevision), this.subscriptionDebounceDelay, (error) => logger.error(`Debounced subscribe failed: ${error?.message ?? error}`));
|
|
313
319
|
// NOTE: Unsubscribe should update local state immediately and batch only the
|
|
314
320
|
// best-effort network announcements to avoid teardown stalls (program close).
|
|
315
|
-
this.debounceUnsubscribeAggregator = debouncedAccumulatorSetCounter((set) => this._announceUnsubscribe([...set.values()]),
|
|
321
|
+
this.debounceUnsubscribeAggregator = debouncedAccumulatorSetCounter((set) => this._announceUnsubscribe([...set.values()], lifecycleRevision), this.subscriptionDebounceDelay, (error) => logger.error(`Debounced unsubscribe announce failed: ${error?.message ?? error}`));
|
|
316
322
|
}
|
|
317
323
|
/**
|
|
318
324
|
* Return a detached, read-only snapshot of effective runtime settings.
|
|
@@ -363,6 +369,10 @@ export class TopicControlPlane extends DirectStream {
|
|
|
363
369
|
// self while a signed-protocol peer is connected.
|
|
364
370
|
if (this.started)
|
|
365
371
|
return;
|
|
372
|
+
// close() is terminal. Only a completed stop/start gets a fresh pair;
|
|
373
|
+
// repeated start() must preserve the active pair's queued reference counts.
|
|
374
|
+
if (this.topicControlPlaneStopping)
|
|
375
|
+
this.createSubscriptionAggregators();
|
|
366
376
|
this.topicControlPlaneStopping = false;
|
|
367
377
|
if (this.autoTopicRootCandidates &&
|
|
368
378
|
!this.localSignedTopicRootCandidateClaim) {
|
|
@@ -407,6 +417,8 @@ export class TopicControlPlane extends DirectStream {
|
|
|
407
417
|
this.clearAutoTopicRootCandidateUpdateSchedule();
|
|
408
418
|
this.clearSignedTopicRootCandidateState();
|
|
409
419
|
this.topicControlPlaneLifecycleRevision += 1;
|
|
420
|
+
this.debounceSubscribeAggregator.close();
|
|
421
|
+
this.debounceUnsubscribeAggregator.close();
|
|
410
422
|
this.reconcileShardOverlaysDirty = false;
|
|
411
423
|
for (const opening of this.ensureFanoutChannelInFlight.values()) {
|
|
412
424
|
opening.abortController.abort(new AbortError("topic control plane stopped"));
|
|
@@ -416,8 +428,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
416
428
|
this.fanout.removeEventListener("fanout:peer-unreachable", this._onFanoutPeerUnreachable);
|
|
417
429
|
}
|
|
418
430
|
for (const st of this.fanoutChannels.values()) {
|
|
419
|
-
|
|
420
|
-
clearTimeout(st.idleCloseTimeout);
|
|
431
|
+
this.clearFanoutIdleClose(st);
|
|
421
432
|
try {
|
|
422
433
|
st.channel.removeEventListener("data", st.onData);
|
|
423
434
|
}
|
|
@@ -463,8 +474,6 @@ export class TopicControlPlane extends DirectStream {
|
|
|
463
474
|
pending.resolve(undefined);
|
|
464
475
|
}
|
|
465
476
|
this.pendingTopicRootQueries.clear();
|
|
466
|
-
this.debounceSubscribeAggregator.close();
|
|
467
|
-
this.debounceUnsubscribeAggregator.close();
|
|
468
477
|
await super.stop();
|
|
469
478
|
this.reconcileShardOverlaysDirty = false;
|
|
470
479
|
}
|
|
@@ -1214,6 +1223,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
1214
1223
|
async reconcileShardOverlays() {
|
|
1215
1224
|
if (!this.started || this.topicControlPlaneStopping)
|
|
1216
1225
|
return;
|
|
1226
|
+
const lifecycleRevision = this.topicControlPlaneLifecycleRevision;
|
|
1217
1227
|
const byShard = new Map();
|
|
1218
1228
|
for (const topic of this.subscriptions.keys()) {
|
|
1219
1229
|
const shardTopic = this.getShardTopicForUserTopic(topic);
|
|
@@ -1238,7 +1248,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
1238
1248
|
if (!st)
|
|
1239
1249
|
return;
|
|
1240
1250
|
await st.channel.publish(toUint8Array(embedded.bytes()));
|
|
1241
|
-
this.touchFanoutChannel(shardTopic);
|
|
1251
|
+
this.touchFanoutChannel(shardTopic, st.channel, lifecycleRevision);
|
|
1242
1252
|
}));
|
|
1243
1253
|
}
|
|
1244
1254
|
isTrackedTopic(topic) {
|
|
@@ -1317,24 +1327,35 @@ export class TopicControlPlane extends DirectStream {
|
|
|
1317
1327
|
}
|
|
1318
1328
|
scheduleFanoutIdleClose(topic) {
|
|
1319
1329
|
const st = this.fanoutChannels.get(topic);
|
|
1320
|
-
|
|
1330
|
+
const lifecycleRevision = this.topicControlPlaneLifecycleRevision;
|
|
1331
|
+
if (!st ||
|
|
1332
|
+
!st.ephemeral ||
|
|
1333
|
+
!this.isTopicControlPlaneActive(lifecycleRevision))
|
|
1321
1334
|
return;
|
|
1322
1335
|
this.clearFanoutIdleClose(st);
|
|
1323
1336
|
if (this.fanoutPublishIdleCloseMs <= 0)
|
|
1324
1337
|
return;
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1338
|
+
const timer = setTimeout(() => {
|
|
1339
|
+
// Cancellation can race a queued callback. It must still own this exact
|
|
1340
|
+
// timer, channel state and lifecycle before acting on the topic again.
|
|
1341
|
+
if (!this.isTopicControlPlaneActive(lifecycleRevision) ||
|
|
1342
|
+
this.fanoutChannels.get(topic) !== st ||
|
|
1343
|
+
st.idleCloseTimeout !== timer ||
|
|
1344
|
+
!st.ephemeral)
|
|
1328
1345
|
return;
|
|
1329
|
-
|
|
1346
|
+
st.idleCloseTimeout = undefined;
|
|
1347
|
+
const idleMs = Date.now() - st.lastUsedAt;
|
|
1330
1348
|
if (idleMs >= this.fanoutPublishIdleCloseMs) {
|
|
1331
1349
|
void this.closeFanoutChannel(topic);
|
|
1332
1350
|
return;
|
|
1333
1351
|
}
|
|
1334
1352
|
this.scheduleFanoutIdleClose(topic);
|
|
1335
1353
|
}, this.fanoutPublishIdleCloseMs);
|
|
1354
|
+
st.idleCloseTimeout = timer;
|
|
1336
1355
|
}
|
|
1337
|
-
touchFanoutChannel(topic) {
|
|
1356
|
+
touchFanoutChannel(topic, channel, lifecycleRevision) {
|
|
1357
|
+
if (!this.isFanoutChannelCurrent(topic, channel, lifecycleRevision))
|
|
1358
|
+
return;
|
|
1338
1359
|
const st = this.fanoutChannels.get(topic);
|
|
1339
1360
|
if (!st)
|
|
1340
1361
|
return;
|
|
@@ -2262,7 +2283,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2262
2283
|
join
|
|
2263
2284
|
.then(() => {
|
|
2264
2285
|
const st = this.fanoutChannels.get(t);
|
|
2265
|
-
if (st === channelState && st.ephemeral) {
|
|
2286
|
+
if (st === channelState && st.ephemeral && isCurrent()) {
|
|
2266
2287
|
this.scheduleFanoutIdleClose(t);
|
|
2267
2288
|
}
|
|
2268
2289
|
})
|
|
@@ -2399,9 +2420,11 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2399
2420
|
this.initializeTopic(topic);
|
|
2400
2421
|
return this.debounceSubscribeAggregator.add({ key: topic });
|
|
2401
2422
|
}
|
|
2402
|
-
async _subscribe(topics) {
|
|
2423
|
+
async _subscribe(topics, lifecycleRevision = this.topicControlPlaneLifecycleRevision) {
|
|
2403
2424
|
if (!this.started)
|
|
2404
2425
|
throw new NotStartedError();
|
|
2426
|
+
if (!this.isTopicControlPlaneActive(lifecycleRevision))
|
|
2427
|
+
return;
|
|
2405
2428
|
if (topics.length === 0)
|
|
2406
2429
|
return;
|
|
2407
2430
|
const byShard = new Map();
|
|
@@ -2422,10 +2445,15 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2422
2445
|
joins.push(this.ensureFanoutChannel(shardTopic));
|
|
2423
2446
|
}
|
|
2424
2447
|
await Promise.all(joins);
|
|
2448
|
+
if (!this.isTopicControlPlaneActive(lifecycleRevision))
|
|
2449
|
+
return;
|
|
2425
2450
|
// Announce subscriptions per shard overlay.
|
|
2426
2451
|
await Promise.all([...byShard.entries()].map(async ([shardTopic, userTopics]) => {
|
|
2427
2452
|
if (userTopics.length === 0)
|
|
2428
2453
|
return;
|
|
2454
|
+
const st = this.fanoutChannels.get(shardTopic);
|
|
2455
|
+
if (!st)
|
|
2456
|
+
throw new Error(`Fanout channel missing for shard: ${shardTopic}`);
|
|
2429
2457
|
const msg = new Subscribe({
|
|
2430
2458
|
topics: userTopics,
|
|
2431
2459
|
requestSubscribers: true,
|
|
@@ -2435,11 +2463,11 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2435
2463
|
priority: 1,
|
|
2436
2464
|
skipRecipientValidation: true,
|
|
2437
2465
|
});
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
throw new Error(`Fanout channel missing for shard: ${shardTopic}`);
|
|
2466
|
+
if (!this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision))
|
|
2467
|
+
return;
|
|
2441
2468
|
await st.channel.publish(toUint8Array(embedded.bytes()));
|
|
2442
|
-
this.
|
|
2469
|
+
if (this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision))
|
|
2470
|
+
this.touchFanoutChannel(shardTopic, st.channel, lifecycleRevision);
|
|
2443
2471
|
}));
|
|
2444
2472
|
}
|
|
2445
2473
|
async unsubscribe(topic, options) {
|
|
@@ -2482,9 +2510,11 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2482
2510
|
.catch(logErrorIfStarted);
|
|
2483
2511
|
return true;
|
|
2484
2512
|
}
|
|
2485
|
-
async _announceUnsubscribe(topics) {
|
|
2513
|
+
async _announceUnsubscribe(topics, lifecycleRevision = this.topicControlPlaneLifecycleRevision) {
|
|
2486
2514
|
if (!this.started)
|
|
2487
2515
|
throw new NotStartedError();
|
|
2516
|
+
if (!this.isTopicControlPlaneActive(lifecycleRevision))
|
|
2517
|
+
return;
|
|
2488
2518
|
const byShard = new Map();
|
|
2489
2519
|
for (const { key: topic } of topics) {
|
|
2490
2520
|
// If the topic got re-subscribed before this debounced batch ran, skip.
|
|
@@ -2496,6 +2526,9 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2496
2526
|
await Promise.all([...byShard.entries()].map(async ([shardTopic, userTopics]) => {
|
|
2497
2527
|
if (userTopics.length === 0)
|
|
2498
2528
|
return;
|
|
2529
|
+
const st = this.fanoutChannels.get(shardTopic);
|
|
2530
|
+
if (!st)
|
|
2531
|
+
return;
|
|
2499
2532
|
// Announce first.
|
|
2500
2533
|
try {
|
|
2501
2534
|
const msg = new Unsubscribe({ topics: userTopics });
|
|
@@ -2504,20 +2537,21 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2504
2537
|
priority: 1,
|
|
2505
2538
|
skipRecipientValidation: true,
|
|
2506
2539
|
});
|
|
2507
|
-
|
|
2508
|
-
if (st) {
|
|
2540
|
+
if (this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision)) {
|
|
2509
2541
|
// Best-effort: do not let a stuck proxy publish stall teardown.
|
|
2510
2542
|
void st.channel
|
|
2511
2543
|
.publish(toUint8Array(embedded.bytes()))
|
|
2512
2544
|
.catch(() => { });
|
|
2513
|
-
this.
|
|
2545
|
+
if (this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision))
|
|
2546
|
+
this.touchFanoutChannel(shardTopic, st.channel, lifecycleRevision);
|
|
2514
2547
|
}
|
|
2515
2548
|
}
|
|
2516
2549
|
catch {
|
|
2517
2550
|
// best-effort
|
|
2518
2551
|
}
|
|
2519
2552
|
// Close shard overlay if no local topics remain.
|
|
2520
|
-
if (
|
|
2553
|
+
if (this.isFanoutChannelCurrent(shardTopic, st.channel, lifecycleRevision) &&
|
|
2554
|
+
(this.shardRefCounts.get(shardTopic) ?? 0) <= 0) {
|
|
2521
2555
|
try {
|
|
2522
2556
|
// Shutdown should be bounded and not depend on network I/O.
|
|
2523
2557
|
await this.closeFanoutChannel(shardTopic);
|
|
@@ -2531,6 +2565,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2531
2565
|
async announcePeerUnavailable(publicKeyHash, batches) {
|
|
2532
2566
|
if (!this.started)
|
|
2533
2567
|
throw new NotStartedError();
|
|
2568
|
+
const lifecycleRevision = this.topicControlPlaneLifecycleRevision;
|
|
2534
2569
|
const byShard = new Map();
|
|
2535
2570
|
for (const batch of batches) {
|
|
2536
2571
|
for (const topic of batch.topics) {
|
|
@@ -2573,7 +2608,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2573
2608
|
const st = this.fanoutChannels.get(shardTopic);
|
|
2574
2609
|
if (st) {
|
|
2575
2610
|
void st.channel.publishMaybe(toUint8Array(embedded.bytes()));
|
|
2576
|
-
this.touchFanoutChannel(shardTopic);
|
|
2611
|
+
this.touchFanoutChannel(shardTopic, st.channel, lifecycleRevision);
|
|
2577
2612
|
}
|
|
2578
2613
|
}
|
|
2579
2614
|
catch {
|
|
@@ -2584,6 +2619,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2584
2619
|
async announcePeerUnavailableOnShard(publicKeyHash, shardTopic) {
|
|
2585
2620
|
if (!this.started)
|
|
2586
2621
|
throw new NotStartedError();
|
|
2622
|
+
const lifecycleRevision = this.topicControlPlaneLifecycleRevision;
|
|
2587
2623
|
try {
|
|
2588
2624
|
const msg = new PeerUnavailable({
|
|
2589
2625
|
publicKeyHash,
|
|
@@ -2600,7 +2636,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2600
2636
|
const st = this.fanoutChannels.get(shardTopic);
|
|
2601
2637
|
if (st) {
|
|
2602
2638
|
void st.channel.publishMaybe(toUint8Array(embedded.bytes()));
|
|
2603
|
-
this.touchFanoutChannel(shardTopic);
|
|
2639
|
+
this.touchFanoutChannel(shardTopic, st.channel, lifecycleRevision);
|
|
2604
2640
|
}
|
|
2605
2641
|
}
|
|
2606
2642
|
catch {
|
|
@@ -2652,6 +2688,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2652
2688
|
async requestSubscribers(topic, to) {
|
|
2653
2689
|
if (!this.started)
|
|
2654
2690
|
throw new NotStartedError();
|
|
2691
|
+
const lifecycleRevision = this.topicControlPlaneLifecycleRevision;
|
|
2655
2692
|
if (topic == null)
|
|
2656
2693
|
throw new Error("ERR_NOT_VALID_TOPIC");
|
|
2657
2694
|
if (topic.length === 0)
|
|
@@ -2695,12 +2732,13 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2695
2732
|
else {
|
|
2696
2733
|
await st.channel.publish(payload);
|
|
2697
2734
|
}
|
|
2698
|
-
this.touchFanoutChannel(shardTopic);
|
|
2735
|
+
this.touchFanoutChannel(shardTopic, st.channel, lifecycleRevision);
|
|
2699
2736
|
}));
|
|
2700
2737
|
}
|
|
2701
2738
|
async publish(data, options) {
|
|
2702
2739
|
if (!this.started)
|
|
2703
2740
|
throw new NotStartedError();
|
|
2741
|
+
const lifecycleRevision = this.topicControlPlaneLifecycleRevision;
|
|
2704
2742
|
const topicsAll = options.topics?.map((x) => x.toString()) || [];
|
|
2705
2743
|
const hasExplicitTOs = options?.mode && deliveryModeHasReceiver(options.mode);
|
|
2706
2744
|
// Explicit recipients: use DirectStream delivery (no shard broadcast).
|
|
@@ -2779,7 +2817,7 @@ export class TopicControlPlane extends DirectStream {
|
|
|
2779
2817
|
throw new Error(`Fanout channel missing for shard: ${shardTopic}`);
|
|
2780
2818
|
}
|
|
2781
2819
|
await withAbort(st.channel.publish(payload), options?.signal);
|
|
2782
|
-
this.touchFanoutChannel(shardTopic);
|
|
2820
|
+
this.touchFanoutChannel(shardTopic, st.channel, lifecycleRevision);
|
|
2783
2821
|
}));
|
|
2784
2822
|
if (this.fanoutPublishIdleCloseMs == 0 ||
|
|
2785
2823
|
this.fanoutPublishMaxEphemeralChannels == 0) {
|