comfy-execution: cache: cache errors is RAM cache sizing scan (#16314)

Some custom nodes hook iterables with side effects and in some cases
these can cause exception in workflows that belong in the past.

Guard against this so comfy stays up and does not trash a workflow
that was innocent based of a bug in a previous workflow.
This commit is contained in:
rattus
2026-09-14 17:36:30 -04:00
committed by GitHub
parent 50ab50c15a
commit a2afcdb899
+8 -1
View File
@@ -1,6 +1,7 @@
import asyncio
import bisect
import itertools
import logging
import time
import torch
from typing import Sequence, Mapping, Dict
@@ -564,6 +565,7 @@ class RAMPressureCache(LRUCache):
ram_usage = RAM_CACHE_DEFAULT_RAM_USAGE
oom_ram_usage = ram_usage
sizing_failed = False
seen_storages = set()
def scan_list_for_ram_usage(outputs):
nonlocal ram_usage, oom_ram_usage
@@ -588,9 +590,14 @@ class RAMPressureCache(LRUCache):
oom_ram_usage = 1e30
elif hasattr(output, "_comfy_cache_tensors"):
scan_list_for_ram_usage(output._comfy_cache_tensors())
try:
scan_list_for_ram_usage(cache_entry.outputs)
except Exception:
logging.warning("Could not size cache entry %s; evicting it first", key, exc_info=True)
sizing_failed = True
oom_ram_usage = 1e30
if ram_usage < min_entry_size:
if not sizing_failed and ram_usage < min_entry_size:
continue
oom_score *= oom_ram_usage