Skip to content

Commit 81bbbe6

Browse files
committed
fix(ui): cap pending log virtualization buffers
1 parent 1141eca commit 81bbbe6

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

packages/ui/src/stores/instances.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,15 @@ function flushPendingLogs() {
105105
continue
106106
}
107107

108+
const boundedQueuedEntries = queuedEntries.length > MAX_LOG_ENTRIES
109+
? queuedEntries.slice(-MAX_LOG_ENTRIES)
110+
: queuedEntries
111+
108112
const target = next ?? prev
109113
const existing = target.get(instanceId) ?? []
110114
const updated = existing.length === 0
111-
? queuedEntries.slice(-MAX_LOG_ENTRIES)
112-
: [...existing, ...queuedEntries].slice(-MAX_LOG_ENTRIES)
115+
? boundedQueuedEntries
116+
: [...existing, ...boundedQueuedEntries].slice(-MAX_LOG_ENTRIES)
113117

114118
if (updated === existing) {
115119
continue
@@ -642,6 +646,9 @@ function addLog(id: string, entry: LogEntry) {
642646
const queued = pendingLogEntries.get(id)
643647
if (queued) {
644648
queued.push(entry)
649+
if (queued.length > MAX_LOG_ENTRIES) {
650+
queued.splice(0, queued.length - MAX_LOG_ENTRIES)
651+
}
645652
} else {
646653
pendingLogEntries.set(id, [entry])
647654
}

0 commit comments

Comments
 (0)