@riddix/hamh 2.1.0-alpha.828 → 2.1.0-alpha.830
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/backend/cli.js
CHANGED
|
@@ -155975,6 +155975,11 @@ function parseSessionMaxAgeHours(raw) {
|
|
|
155975
155975
|
if (n > max) return max;
|
|
155976
155976
|
return n;
|
|
155977
155977
|
}
|
|
155978
|
+
var DEAD_SESSION_TIMEOUT_MS = 6e4;
|
|
155979
|
+
var FAST_DEAD_SESSION_TIMEOUT_MS = 5e3;
|
|
155980
|
+
function deadSessionTimeoutMs(flags2) {
|
|
155981
|
+
return flags2?.fastSessionRecovery ? FAST_DEAD_SESSION_TIMEOUT_MS : DEAD_SESSION_TIMEOUT_MS;
|
|
155982
|
+
}
|
|
155978
155983
|
var STALE_SESSION_QUIET_WINDOW_MS = 5 * 60 * 1e3;
|
|
155979
155984
|
function staleSessionQuietWindowMs(flags2) {
|
|
155980
155985
|
return flags2?.fastSessionRecovery ? 0 : STALE_SESSION_QUIET_WINDOW_MS;
|
|
@@ -156009,11 +156014,6 @@ function seedExistingSessionStarts(startedAt, sessions, now = Date.now()) {
|
|
|
156009
156014
|
|
|
156010
156015
|
// src/services/bridges/bridge.ts
|
|
156011
156016
|
var AUTO_FORCE_SYNC_INTERVAL_MS = 9e4;
|
|
156012
|
-
var DEAD_SESSION_TIMEOUT_MS = 6e4;
|
|
156013
|
-
var FAST_DEAD_SESSION_TIMEOUT_MS = 5e3;
|
|
156014
|
-
function deadSessionTimeoutMs(flags2) {
|
|
156015
|
-
return flags2?.fastSessionRecovery ? FAST_DEAD_SESSION_TIMEOUT_MS : DEAD_SESSION_TIMEOUT_MS;
|
|
156016
|
-
}
|
|
156017
156017
|
var SHUTDOWN_SESSION_CLOSE_TIMEOUT_MS = 2500;
|
|
156018
156018
|
var MDNS_ADDRESS_CHECK_INTERVAL_MS = 6e4;
|
|
156019
156019
|
var Bridge = class {
|
|
@@ -173003,7 +173003,6 @@ init_esm7();
|
|
|
173003
173003
|
import * as os10 from "node:os";
|
|
173004
173004
|
init_diagnostic_event_bus();
|
|
173005
173005
|
var AUTO_FORCE_SYNC_INTERVAL_MS2 = 9e4;
|
|
173006
|
-
var DEAD_SESSION_TIMEOUT_MS2 = 6e4;
|
|
173007
173006
|
var SHUTDOWN_SESSION_CLOSE_TIMEOUT_MS2 = 2500;
|
|
173008
173007
|
var MDNS_ADDRESS_CHECK_INTERVAL_MS2 = 6e4;
|
|
173009
173008
|
function makeWarmStartState(state, now = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
@@ -173286,17 +173285,34 @@ ${e?.toString()}`);
|
|
|
173286
173285
|
this.log.debug(
|
|
173287
173286
|
`Session ${session.id} (peer ${session.peerNodeId}): subscriptions=${session.subscriptions.size} | total: sessions=${sessions.length} subscriptions=${totalSubs}`
|
|
173288
173287
|
);
|
|
173288
|
+
diagnosticEventBus.emit(
|
|
173289
|
+
"subscription_changed",
|
|
173290
|
+
`Session ${session.id}: ${session.subscriptions.size} subs (total ${totalSubs})`,
|
|
173291
|
+
{
|
|
173292
|
+
bridgeId: this.data.id,
|
|
173293
|
+
bridgeName: this.data.name,
|
|
173294
|
+
details: {
|
|
173295
|
+
sessionId: session.id,
|
|
173296
|
+
sessionSubs: session.subscriptions.size,
|
|
173297
|
+
totalSessions: sessions.length,
|
|
173298
|
+
totalSubs
|
|
173299
|
+
}
|
|
173300
|
+
}
|
|
173301
|
+
);
|
|
173289
173302
|
if (totalSubs === 0 && sessions.length > 0) {
|
|
173290
173303
|
this.log.warn(
|
|
173291
173304
|
`All subscriptions lost, ${sessions.length} session(s) still active, waiting for controller to re-subscribe`
|
|
173292
173305
|
);
|
|
173293
173306
|
if (!this.deadSessionTimer) {
|
|
173307
|
+
const timeoutMs = deadSessionTimeoutMs(
|
|
173308
|
+
this.dataProvider.featureFlags
|
|
173309
|
+
);
|
|
173294
173310
|
this.deadSessionTimer = setTimeout(() => {
|
|
173295
173311
|
this.deadSessionTimer = null;
|
|
173296
173312
|
this.closeDeadSessions();
|
|
173297
|
-
},
|
|
173313
|
+
}, timeoutMs);
|
|
173298
173314
|
this.log.info(
|
|
173299
|
-
`Scheduled dead session cleanup in ${
|
|
173315
|
+
`Scheduled dead session cleanup in ${timeoutMs / 1e3}s`
|
|
173300
173316
|
);
|
|
173301
173317
|
}
|
|
173302
173318
|
} else if (totalSubs > 0 && this.deadSessionTimer) {
|
|
@@ -173312,7 +173328,7 @@ ${e?.toString()}`);
|
|
|
173312
173328
|
setTimeout(() => {
|
|
173313
173329
|
this.staleSessionTimers.delete(session.id);
|
|
173314
173330
|
this.closeStaleSession(session.id);
|
|
173315
|
-
},
|
|
173331
|
+
}, deadSessionTimeoutMs(this.dataProvider.featureFlags))
|
|
173316
173332
|
);
|
|
173317
173333
|
} else if (session.subscriptions.size > 0 && this.staleSessionTimers.has(session.id)) {
|
|
173318
173334
|
clearTimeout(this.staleSessionTimers.get(session.id));
|
|
@@ -173325,6 +173341,15 @@ ${e?.toString()}`);
|
|
|
173325
173341
|
this.log.info(
|
|
173326
173342
|
`Session opened: id=${newSession.id} peer=${newSession.peerNodeId}`
|
|
173327
173343
|
);
|
|
173344
|
+
diagnosticEventBus.emit(
|
|
173345
|
+
"session_opened",
|
|
173346
|
+
`Session ${newSession.id} opened (peer ${newSession.peerNodeId})`,
|
|
173347
|
+
{
|
|
173348
|
+
bridgeId: this.data.id,
|
|
173349
|
+
bridgeName: this.data.name,
|
|
173350
|
+
details: { sessionId: newSession.id }
|
|
173351
|
+
}
|
|
173352
|
+
);
|
|
173328
173353
|
for (const s of [...sessionManager.sessions]) {
|
|
173329
173354
|
if (s !== newSession && !s.isClosing && s.peerNodeId === newSession.peerNodeId && s.fabric?.fabricIndex === newSession.fabric?.fabricIndex && s.subscriptions.size === 0) {
|
|
173330
173355
|
this.log.info(
|
|
@@ -173373,6 +173398,18 @@ ${e?.toString()}`);
|
|
|
173373
173398
|
this.log.warn(
|
|
173374
173399
|
`Session closed: id=${session.id} peer=${session.peerNodeId} | remaining sessions=${sessions.length}`
|
|
173375
173400
|
);
|
|
173401
|
+
diagnosticEventBus.emit(
|
|
173402
|
+
"session_closed",
|
|
173403
|
+
`Session ${session.id} closed (peer ${session.peerNodeId})`,
|
|
173404
|
+
{
|
|
173405
|
+
bridgeId: this.data.id,
|
|
173406
|
+
bridgeName: this.data.name,
|
|
173407
|
+
details: {
|
|
173408
|
+
sessionId: session.id,
|
|
173409
|
+
remainingSessions: sessions.length
|
|
173410
|
+
}
|
|
173411
|
+
}
|
|
173412
|
+
);
|
|
173376
173413
|
};
|
|
173377
173414
|
sessionManager.sessions.added.on(this.sessionAddedHandler);
|
|
173378
173415
|
sessionManager.sessions.deleted.on(this.sessionDeletedHandler);
|
|
@@ -173400,12 +173437,12 @@ ${e?.toString()}`);
|
|
|
173400
173437
|
setTimeout(() => {
|
|
173401
173438
|
this.staleSessionTimers.delete(sessionId);
|
|
173402
173439
|
this.closeStaleSession(sessionId);
|
|
173403
|
-
},
|
|
173440
|
+
}, deadSessionTimeoutMs(this.dataProvider.featureFlags))
|
|
173404
173441
|
);
|
|
173405
173442
|
break;
|
|
173406
173443
|
}
|
|
173407
173444
|
this.log.warn(
|
|
173408
|
-
`Closing stale session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${
|
|
173445
|
+
`Closing stale session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${deadSessionTimeoutMs(this.dataProvider.featureFlags) / 1e3}s, no traffic for ${idleSec}s)`
|
|
173409
173446
|
);
|
|
173410
173447
|
s.initiateClose().catch(() => {
|
|
173411
173448
|
return s.initiateForceClose({
|
|
@@ -173440,7 +173477,7 @@ ${e?.toString()}`);
|
|
|
173440
173477
|
continue;
|
|
173441
173478
|
}
|
|
173442
173479
|
this.log.warn(
|
|
173443
|
-
`Closing dead session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${
|
|
173480
|
+
`Closing dead session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${deadSessionTimeoutMs(this.dataProvider.featureFlags) / 1e3}s, no traffic for ${idleSec}s)`
|
|
173444
173481
|
);
|
|
173445
173482
|
closes.push(
|
|
173446
173483
|
s.initiateClose().catch(() => {
|
|
@@ -173454,7 +173491,7 @@ ${e?.toString()}`);
|
|
|
173454
173491
|
this.deadSessionTimer = setTimeout(() => {
|
|
173455
173492
|
this.deadSessionTimer = null;
|
|
173456
173493
|
this.closeDeadSessions();
|
|
173457
|
-
},
|
|
173494
|
+
}, deadSessionTimeoutMs(this.dataProvider.featureFlags));
|
|
173458
173495
|
}
|
|
173459
173496
|
if (closes.length > 0) {
|
|
173460
173497
|
Promise.allSettled(closes).then(() => this.triggerMdnsReAnnounce());
|