@riddix/hamh 2.1.0-alpha.788 → 2.1.0-alpha.790
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
|
@@ -148888,8 +148888,17 @@ function parseSessionMaxAgeHours(raw) {
|
|
|
148888
148888
|
if (n > max) return max;
|
|
148889
148889
|
return n;
|
|
148890
148890
|
}
|
|
148891
|
-
|
|
148892
|
-
|
|
148891
|
+
var STALE_SESSION_QUIET_WINDOW_MS = 5 * 60 * 1e3;
|
|
148892
|
+
function staleSessionQuietWindowMs(flags2) {
|
|
148893
|
+
return flags2?.fastSessionRecovery ? 0 : STALE_SESSION_QUIET_WINDOW_MS;
|
|
148894
|
+
}
|
|
148895
|
+
function staleSessionShouldClose(session, quietWindowMs = STALE_SESSION_QUIET_WINDOW_MS, now = Date.now()) {
|
|
148896
|
+
if (session.subscriptions.size > 0 || session.isClosing) return false;
|
|
148897
|
+
if (session.isPeerActive) return false;
|
|
148898
|
+
if (quietWindowMs > 0 && typeof session.timestamp === "number" && now - session.timestamp < quietWindowMs) {
|
|
148899
|
+
return false;
|
|
148900
|
+
}
|
|
148901
|
+
return true;
|
|
148893
148902
|
}
|
|
148894
148903
|
function seedExistingSessionStarts(startedAt, sessions, now = Date.now()) {
|
|
148895
148904
|
for (const session of sessions) {
|
|
@@ -149309,9 +149318,13 @@ ${e?.toString()}`);
|
|
|
149309
149318
|
if (s.id !== sessionId || s.isClosing || s.subscriptions.size > 0) {
|
|
149310
149319
|
continue;
|
|
149311
149320
|
}
|
|
149312
|
-
|
|
149321
|
+
const idleSec = Math.round((Date.now() - s.timestamp) / 1e3);
|
|
149322
|
+
if (!staleSessionShouldClose(
|
|
149323
|
+
s,
|
|
149324
|
+
staleSessionQuietWindowMs(this.dataProvider.featureFlags)
|
|
149325
|
+
)) {
|
|
149313
149326
|
this.log.info(
|
|
149314
|
-
`Keeping session ${s.id} (peer ${s.peerNodeId}, 0 subs
|
|
149327
|
+
`Keeping session ${s.id} (peer ${s.peerNodeId}, 0 subs, last traffic ${idleSec}s ago)`
|
|
149315
149328
|
);
|
|
149316
149329
|
this.staleSessionTimers.set(
|
|
149317
149330
|
sessionId,
|
|
@@ -149323,7 +149336,7 @@ ${e?.toString()}`);
|
|
|
149323
149336
|
break;
|
|
149324
149337
|
}
|
|
149325
149338
|
this.log.warn(
|
|
149326
|
-
`Closing stale session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${deadSessionTimeoutMs(this.dataProvider.featureFlags) / 1e3}s)`
|
|
149339
|
+
`Closing stale session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${deadSessionTimeoutMs(this.dataProvider.featureFlags) / 1e3}s, no traffic for ${idleSec}s)`
|
|
149327
149340
|
);
|
|
149328
149341
|
s.initiateClose().catch(() => {
|
|
149329
149342
|
return s.initiateForceClose({
|
|
@@ -149346,12 +149359,19 @@ ${e?.toString()}`);
|
|
|
149346
149359
|
if (s.isClosing || s.subscriptions.size > 0) {
|
|
149347
149360
|
continue;
|
|
149348
149361
|
}
|
|
149349
|
-
|
|
149362
|
+
const idleSec = Math.round((Date.now() - s.timestamp) / 1e3);
|
|
149363
|
+
if (!staleSessionShouldClose(
|
|
149364
|
+
s,
|
|
149365
|
+
staleSessionQuietWindowMs(this.dataProvider.featureFlags)
|
|
149366
|
+
)) {
|
|
149367
|
+
this.log.info(
|
|
149368
|
+
`Keeping session ${s.id} (peer ${s.peerNodeId}, 0 subs, last traffic ${idleSec}s ago)`
|
|
149369
|
+
);
|
|
149350
149370
|
kept++;
|
|
149351
149371
|
continue;
|
|
149352
149372
|
}
|
|
149353
149373
|
this.log.warn(
|
|
149354
|
-
`Closing dead session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${deadSessionTimeoutMs(this.dataProvider.featureFlags) / 1e3}s)`
|
|
149374
|
+
`Closing dead session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${deadSessionTimeoutMs(this.dataProvider.featureFlags) / 1e3}s, no traffic for ${idleSec}s)`
|
|
149355
149375
|
);
|
|
149356
149376
|
closes.push(
|
|
149357
149377
|
s.initiateClose().catch(() => {
|
|
@@ -165353,9 +165373,13 @@ ${e?.toString()}`);
|
|
|
165353
165373
|
if (s.id !== sessionId || s.isClosing || s.subscriptions.size > 0) {
|
|
165354
165374
|
continue;
|
|
165355
165375
|
}
|
|
165356
|
-
|
|
165376
|
+
const idleSec = Math.round((Date.now() - s.timestamp) / 1e3);
|
|
165377
|
+
if (!staleSessionShouldClose(
|
|
165378
|
+
s,
|
|
165379
|
+
staleSessionQuietWindowMs(this.dataProvider.featureFlags)
|
|
165380
|
+
)) {
|
|
165357
165381
|
this.log.info(
|
|
165358
|
-
`Keeping session ${s.id} (peer ${s.peerNodeId}, 0 subs
|
|
165382
|
+
`Keeping session ${s.id} (peer ${s.peerNodeId}, 0 subs, last traffic ${idleSec}s ago)`
|
|
165359
165383
|
);
|
|
165360
165384
|
this.staleSessionTimers.set(
|
|
165361
165385
|
sessionId,
|
|
@@ -165367,7 +165391,7 @@ ${e?.toString()}`);
|
|
|
165367
165391
|
break;
|
|
165368
165392
|
}
|
|
165369
165393
|
this.log.warn(
|
|
165370
|
-
`Closing stale session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS2 / 1e3}s)`
|
|
165394
|
+
`Closing stale session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS2 / 1e3}s, no traffic for ${idleSec}s)`
|
|
165371
165395
|
);
|
|
165372
165396
|
s.initiateClose().catch(() => {
|
|
165373
165397
|
return s.initiateForceClose({
|
|
@@ -165390,12 +165414,19 @@ ${e?.toString()}`);
|
|
|
165390
165414
|
if (s.isClosing || s.subscriptions.size > 0) {
|
|
165391
165415
|
continue;
|
|
165392
165416
|
}
|
|
165393
|
-
|
|
165417
|
+
const idleSec = Math.round((Date.now() - s.timestamp) / 1e3);
|
|
165418
|
+
if (!staleSessionShouldClose(
|
|
165419
|
+
s,
|
|
165420
|
+
staleSessionQuietWindowMs(this.dataProvider.featureFlags)
|
|
165421
|
+
)) {
|
|
165422
|
+
this.log.info(
|
|
165423
|
+
`Keeping session ${s.id} (peer ${s.peerNodeId}, 0 subs, last traffic ${idleSec}s ago)`
|
|
165424
|
+
);
|
|
165394
165425
|
kept++;
|
|
165395
165426
|
continue;
|
|
165396
165427
|
}
|
|
165397
165428
|
this.log.warn(
|
|
165398
|
-
`Closing dead session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS2 / 1e3}s)`
|
|
165429
|
+
`Closing dead session ${s.id} (peer ${s.peerNodeId}, no subscriptions for ${DEAD_SESSION_TIMEOUT_MS2 / 1e3}s, no traffic for ${idleSec}s)`
|
|
165399
165430
|
);
|
|
165400
165431
|
closes.push(
|
|
165401
165432
|
s.initiateClose().catch(() => {
|