fix: harden session cache + heartbeat restore

Co-authored-by: Ronak Guliani <ronak-guliani@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-01-15 07:05:37 +00:00
parent 04ebf8d67a
commit 1c96477686
8 changed files with 132 additions and 30 deletions

View File

@@ -148,8 +148,9 @@ async function restoreHeartbeatUpdatedAt(params: {
const store = loadSessionStore(storePath);
const entry = store[sessionKey];
if (!entry) return;
if (entry.updatedAt === updatedAt) return;
store[sessionKey] = { ...entry, updatedAt };
const nextUpdatedAt = Math.max(entry.updatedAt ?? 0, updatedAt);
if (entry.updatedAt === nextUpdatedAt) return;
store[sessionKey] = { ...entry, updatedAt: nextUpdatedAt };
await saveSessionStore(storePath, store);
}