From a2afcdb89910f7ada92e2a6e04c8b5c9126122f1 Mon Sep 17 00:00:00 2001 From: rattus <46076784+rattus128@users.noreply.github.com> Date: Tue, 15 Sep 2026 07:36:30 +1000 Subject: [PATCH] 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. --- comfy_execution/caching.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/comfy_execution/caching.py b/comfy_execution/caching.py index 9ff52fc48..25f471feb 100644 --- a/comfy_execution/caching.py +++ b/comfy_execution/caching.py @@ -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()) - scan_list_for_ram_usage(cache_entry.outputs) + 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