MCPcopy Create free account
hub / github.com/tiann/hapi / expireInactive

Method expireInactive

hub/src/sync/syncEngine.ts:336–351  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

334 }
335
336 private expireInactive(): void {
337 const expired = this.sessionCache.expireInactive()
338 // Sort by most recent first so dedup keeps the newest session when multiple
339 // duplicates for the same agent thread expire in the same sweep.
340 const sorted = expired
341 .map((id) => this.sessionCache.getSession(id))
342 .filter((s): s is NonNullable<typeof s> => s != null)
343 .sort((a, b) => (b.activeAt - a.activeAt) || (b.updatedAt - a.updatedAt))
344 for (const session of sorted) {
345 this.triggerDedupIfNeeded(session.id)
346 }
347 this.machineCache.expireInactive()
348 // Piggybacked on the inactivity tick; not a logical part of expireInactive
349 // but shares its 5s cadence (avoids a second timer).
350 this.messageService.releaseMatureScheduledMessages(Date.now())
351 }
352
353 private reloadAll(): void {
354 this.sessionCache.reloadAll()

Callers 2

constructorMethod · 0.95

Calls 3

triggerDedupIfNeededMethod · 0.95
getSessionMethod · 0.45

Tested by

no test coverage detected