fix(nodes): snapshot scanner cache before iterating on executor thread

Node code reads cache.raw_data while MetadataSyncService may mutate it
from a background thread; iterate over a list() snapshot to avoid a
possible 'list changed size during iteration' RuntimeError.
This commit is contained in:
Will Miao
2026-09-14 11:05:12 +08:00
parent 326df32933
commit db38ad80e6
4 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -78,7 +78,7 @@ class CheckpointLoaderLM:
# Filter only checkpoint type (not diffusion_model) and format names # Filter only checkpoint type (not diffusion_model) and format names
names = [] names = []
for item in cache.raw_data: for item in list(cache.raw_data):
if item.get("sub_type") == "checkpoint": if item.get("sub_type") == "checkpoint":
file_path = item.get("file_path", "") file_path = item.get("file_path", "")
# Only offer models that still exist on disk so ComfyUI # Only offer models that still exist on disk so ComfyUI
@@ -126,7 +126,7 @@ class CheckpointLoaderLM:
cache = await scanner.get_cached_data() cache = await scanner.get_cached_data()
base_models = set() base_models = set()
for item in cache.raw_data: for item in list(cache.raw_data):
if item.get("sub_type") != "checkpoint": if item.get("sub_type") != "checkpoint":
continue continue
base_model = item.get("base_model") base_model = item.get("base_model")
+1 -1
View File
@@ -601,7 +601,7 @@ class SaveImageLM:
os.path.basename(name), os.path.basename(name),
os.path.splitext(os.path.basename(name))[0], os.path.splitext(os.path.basename(name))[0],
] ]
for model in getattr(cache, "raw_data", []): for model in list(getattr(cache, "raw_data", [])):
file_name = model.get("file_name") file_name = model.get("file_name")
if file_name in candidates: if file_name in candidates:
return model return model
+2 -2
View File
@@ -93,7 +93,7 @@ class UNETLoaderLM:
# Filter only diffusion_model type and format names # Filter only diffusion_model type and format names
names = [] names = []
for item in cache.raw_data: for item in list(cache.raw_data):
if item.get("sub_type") == "diffusion_model": if item.get("sub_type") == "diffusion_model":
file_path = item.get("file_path", "") file_path = item.get("file_path", "")
# Only offer models that still exist on disk so ComfyUI # Only offer models that still exist on disk so ComfyUI
@@ -141,7 +141,7 @@ class UNETLoaderLM:
cache = await scanner.get_cached_data() cache = await scanner.get_cached_data()
base_models = set() base_models = set()
for item in cache.raw_data: for item in list(cache.raw_data):
if item.get("sub_type") != "diffusion_model": if item.get("sub_type") != "diffusion_model":
continue continue
base_model = item.get("base_model") base_model = item.get("base_model")
+1 -1
View File
@@ -156,7 +156,7 @@ def _find_missing_loras(names: list[str]) -> list[str]:
lookup = {} lookup = {}
basename_candidates = {} basename_candidates = {}
for item in cache.raw_data: for item in list(cache.raw_data):
file_path = item.get("file_path") file_path = item.get("file_path")
if not file_path: if not file_path:
continue continue