fix(sync): drop orphan session parts (#1183)
* fix(sync): drop orphan session parts * fix(sync): guard missing part cache --------- Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
b944bd812c
commit
e50a484633
@@ -56,6 +56,17 @@ export function dropSessionCaches(store: SessionCache, sessionIDs: Iterable<stri
|
||||
const stale = new Set(Array.from(sessionIDs).filter(Boolean))
|
||||
if (stale.size === 0) return
|
||||
|
||||
const staleMessageIDs = new Set<string>()
|
||||
for (const sessionID of stale) {
|
||||
for (const message of store.message?.[sessionID] ?? []) {
|
||||
if (message?.id) staleMessageIDs.add(message.id)
|
||||
}
|
||||
}
|
||||
|
||||
for (const messageID of staleMessageIDs) {
|
||||
if (store.part) delete store.part[messageID]
|
||||
}
|
||||
|
||||
for (const key of Object.keys(store.part ?? {})) {
|
||||
const parts = store.part[key]
|
||||
if (!parts?.some((part) => stale.has((part as { sessionID?: string })?.sessionID ?? "")))
|
||||
|
||||
Reference in New Issue
Block a user