fix(ui): logs page error no longer flickers, live entries pruned, unavailable clears (#1746)
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:
1 file changed
+13
-1
+13
-1
@@ -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" &&
|
||||
|
||||
Reference in new issue
Block a user