Fix: Windows access violation during startup when loading comfy_api_nodes (pydantic-core GC issue)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
The changes go in comfy_api_nodes/apis/__init__.py and nodes.py inside init_builtin_api_nodes(). Wrap the model imports and node loading with gc.disable()/gc.enable() as specified. Done means ComfyUI starts on Windows without the access violation after multiple runs.
Written by the indexing model from the issue text.
Description
Problem
On Windows, ComfyUI crashes at startup with Windows fatal exception: access violation while loading the built-in API nodes (comfy_api_nodes). The stack trace points to pydantic's schema generation, triggered during import of comfy_api_nodes/apis/__init__.py (a file with ~1000+ pydantic models).
Root cause
This is a known bug in pydantic-core on Windows: the cyclic garbage collector traverses pydantic-core's internal objects (validators/serializers) while they are still being constructed, corrupting refcounts and causing the access violation. Tracked in pydantic discussion #13839.
Fix
Disable the cyclic GC while constructing all pydantic models in apis/__init__.py and during the loading of built-in API nodes:
In comfy_api_nodes/apis/__init__.py (add at the top):
import gc as _gc
_gc_was_enabled = _gc.isenabled()
_gc.disable()
And at the very end of the file:
if _gc_was_enabled:
_gc.enable()
In nodes.py -> init_builtin_api_nodes():
import gc
gc_was_enabled = gc.isenabled()
gc.disable()
try:
for node_file in api_nodes_files:
if not await load_custom_node(node_file, module_parent="comfy_api_nodes"):
import_failed.append(os.path.basename(node_file))
finally:
if gc_was_enabled:
gc.enable()
Verification
Tested across 8 consecutive startup runs — all completed successfully with no access violations.
Environment
- Windows 11, Python 3.12.10
- pydantic 2.14.2, pydantic-core 2.50.2
- ComfyUI 0.42.5
- Dominant language
- Python
- Stars
- 146k
- Forks
- 17.4k
- Avg merge
- 19h 44m
- Merged PRs (30d)
- 178
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Comfy-Org/ComfyUI
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
ROCm gfx1100: contiguous-k/v SDPA workaround is gfx1151-only, MiniMax H3 sampling 2.2x slower on RX 7900 XTXPossibly taken @TwelveNights claimed this 3 days ago. OpenPotential Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Sub-quadratic attention is ~10x slower on long sequences on RDNA2 (gfx1030) because the key passed to bmm is non-contiguousPossibly taken @KornienkoDev claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
MoGe-3 output is nondeterministic on CUDA: sparse_pool3d_mean sums with float index_add_ (atomics)Possibly taken @potoior claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Comfy-Org/ComfyUI#17498 · 1 comment ·
Maintainers usually reply within 1 day
-
TRELLIS.2 texture bake fails under --bf16-vae: BakeTextureFromVoxel 'Got unsupported ScalarType BFloat16'Possibly taken @Shubham-Padkonde claimed this 10 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
All issues in Comfy-Org/ComfyUI
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
OCA/account-invoicing#2529 ·
Maintainers usually reply within 1 day
-
area/ci
Difficulty 1/5 Under an hour Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
ImageGen generate-batch aborts valid JSONL jobs containing a Unicode line separator in poster textOpenbug imagen skills
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Email validation accepts a trailing newlinePossibly taken @marcello-pichini claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day