fix(ui): logs page error no longer flickers, live entries pruned, unavailable clears (#1746)
Quality / check (push) Canceled after 2m59s
deploy / gate (push) Successful in 4m51s
deploy / archied-image (push) Successful in 3m28s
deploy / agent-image (push) Successful in 11s
deploy / dist-zip (push) Skipped

readError is cleared only by a successful read instead of at the start of
every 5 s refresh, so an outage shows a steady error beside the stale
lines. liveEntries is pruned past 1500 (the list shows 1000) so the map
cannot grow unbounded. streamState leaves "unavailable" as soon as live
entries flow again.
This commit is contained in:
sam committed 2026-11-07 00:22:40 +11:00
1 parent 9ca9545847
commit 45494d5b43
1 file changed
+13 -1
+13 -1
View File
@@ -87,7 +87,8 @@ let generation=0;
export async function loadLogs(): Promise<void> {
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<LogHistory>({
service:filters.service,
@@ -97,6 +98,7 @@ export async function loadLogs(): Promise<void> {
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" &&