mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
fix: guard maxEntries against negative values in createSessionTabMap
Addresses review feedback: https://github.com/Comfy-Org/ComfyUI_frontend/pull/10689#discussion_r3007061640
This commit is contained in:
@@ -11,6 +11,7 @@ export function createSessionTabMap(
|
||||
prefix: string,
|
||||
maxEntries: number = 200
|
||||
): SessionTabMap {
|
||||
const capacity = Math.max(0, Math.floor(maxEntries))
|
||||
const map = shallowRef<Map<string, string>>(restore(prefix))
|
||||
|
||||
function set(key: string, value: string): void {
|
||||
@@ -19,8 +20,9 @@ export function createSessionTabMap(
|
||||
next.delete(key)
|
||||
next.set(key, value)
|
||||
|
||||
while (next.size > maxEntries) {
|
||||
const oldest = next.keys().next().value!
|
||||
while (next.size > capacity) {
|
||||
const oldest = next.keys().next().value
|
||||
if (oldest === undefined) break
|
||||
next.delete(oldest)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user