diff --git a/ui/src/logs/state.ts b/ui/src/logs/state.ts index 8c853474a..1f1efdf08 100644 --- a/ui/src/logs/state.ts +++ b/ui/src/logs/state.ts @@ -87,7 +87,8 @@ let generation=0; export async function loadLogs(): Promise { const current=++generation; loading.value = true; - readError.value = null; + // readError is cleared only by a successful read below: clearing it here + // makes the error and the stale lines alternate on every 5 s refresh. try { const res = await api.logs({ service:filters.service, @@ -97,6 +98,7 @@ export async function loadLogs(): Promise { limit: 500, }); if(current!==generation)return; + readError.value = null; serviceOptions.value=[...new Set([...serviceOptions.value,...(res.services??[])])].sort(); serviceErrors.value=res.errors??{}; componentOptions.value = res.components ?? []; @@ -122,7 +124,17 @@ function handleEntry(raw: unknown): void { const entry = raw as LogEntry; if (!matchesFilters(entry, filters)) return; + if (streamState.value === "unavailable") streamState.value = "live"; liveEntries.set(entryKey(entry), entry); + // The list shows only the last 1000; keep a margin and drop the oldest so + // the map cannot grow without bound while the page stays open. + if (liveEntries.size > 1500) { + let excess = liveEntries.size - 1500; + for (const key of liveEntries.keys()) { + liveEntries.delete(key); + if (--excess <= 0) break; + } + } const component = entry.fields?.component; if ( typeof component === "string" &&