Commit Graph

2 Commits

Author SHA1 Message Date
Jedrzej Kosinski
97e84d399c test: scope nodes stub to a fixture to avoid sys.modules leakage
Per coderabbit feedback: replace the module-level sys.modules['nodes'] = stub
with a per-test fixture using monkeypatch.setitem so the fake module is torn
down after each test, and reload app.node_replace_manager so it picks up the
stub instead of any cached real import.

Amp-Thread-ID: https://ampcode.com/threads/T-019dd37c-4751-72ef-9927-3182b5825db0
Co-authored-by: Amp <amp@ampcode.com>
2026-04-28 03:14:45 -07:00
Jedrzej Kosinski
2ff1d3d042 fix: make NodeReplaceManager.register() idempotent
When the same (old_node_id, new_node_id) pair is registered more than
once in the same process, the duplicate is now silently ignored (with a
debug log). Previously every call appended a new entry, so reloading a
custom node — e.g. via ComfyUI-Manager hot-reload — would accumulate
stale duplicate replacements that surfaced through GET /node_replacements.

Multiple distinct alternatives for the same old_node_id (different
new_node_ids) are still preserved, matching the existing 'list of
alternatives' design used by apply_replacements().

Adds unit tests in tests-unit/app_test/node_replace_manager_test.py
covering normal registration, multi-alternative support, dedupe, and
first-write-wins ordering.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dd37c-4751-72ef-9927-3182b5825db0
2026-04-28 03:03:41 -07:00