Comfy-Org / Comfy-Org/ComfyUI

Expanded node subcaches skip external CacheProvider lookup and store

Open Beginner friendly
#15,948 0 comments 0 reactions 0 assignees View on GitHub
Potential Bug
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

### Custom Node Testing

- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)

### Expected Behavior

Expanded nodes created by node expansion should use external CacheProvider lookup and store when their parent output cache has `enable_providers=True`.

Subcaches belonging to caches with providers disabled, such as the object cache, should continue to skip external providers.

### Actual Behavior

`BasicCache._ensure_subcache()` creates expanded-node subcaches with:

BasicCache(self.key_class)

Because `enable_providers` defaults to `False`, a parent output cache with providers enabled creates child subcaches with providers disabled. External lookup and store are therefore skipped for expanded nodes.

### Steps to Reproduce

1. Register a mock CacheProvider that records `on_lookup` and `on_store` calls.
2. Create a `HierarchicalCache` with `enable_providers=True`.
3. Add an ephemeral child node and call `ensure_subcache_for()` for its parent.
4. Store a cacheable child value.
5. Clear the local child entry and request it again.
6. Observe that neither provider callback is called.

### Debug Logs

```powershell
parent.enable_providers: True
subcache.enable_providers: False
provider.on_store calls: 0
provider.on_lookup calls: 0
```

### Other

The original CacheProvider change, commit af7b4a92, explicitly included "fix: enable external caching for subcache (expanded) nodes".

Commit 4a8cf359 later added the `enable_providers` flag to restrict providers to output caches, but `_ensure_subcache()` did not propagate the flag. Passing the parent value preserves both intended behaviors:

- output cache: True -> expanded subcache: True
- object cache: False -> expanded subcache: False

Contributor guide

Open the contributing guide

Research direction

Find BasicCache._ensure_subcache() and inspect how it constructs expanded-node subcaches, then trace enable_providers through HierarchicalCache and CacheProvider. Reproduce the issue with a mock provider using the listed steps, including clearing the local child entry. Done means provider lookup and store callbacks occur for output-cache subcaches while object-cache subcaches still skip external providers.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.