Files
ComfyUI_frontend/src/scripts
Christian Byrne 80d75bb164 fix TypeError: nodes is not iterable when loading graph (#5660)
## Summary
- Fixes Sentry issue CLOUD-FRONTEND-STAGING-29 (TypeError: nodes is not
iterable)
- Adds defensive guard to check if nodes is valid array before iteration
- Gracefully handles malformed workflow data by skipping node processing

## Root Cause
The `collectMissingNodesAndModels` function in `src/scripts/app.ts:1135`
was attempting to iterate over `nodes` without checking if it was a
valid iterable, causing crashes when workflow data was malformed or
missing the nodes property.

## Fix
Added null/undefined/array validation before the for-loop:
```typescript
if (\!nodes || \!Array.isArray(nodes)) {
  console.warn('Workflow nodes data is missing or invalid, skipping node processing', { nodes, path })
  return
}
```

Fixes CLOUD-FRONTEND-STAGING-29

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-5660-fix-TypeError-nodes-is-not-iterable-when-loading-graph-2736d73d365081cfb828d27e59a4811c)
by [Unito](https://www.unito.io)
2025-09-18 23:27:42 -07:00
..
2025-09-07 01:10:32 -07:00

Scripts Directory Documentation

This directory contains TypeScript code inherited from the legacy ComfyUI JavaScript frontend project. The code has been migrated from JavaScript to TypeScript while maintaining compatibility with the original functionality.

When implementing new features, prefer using the new Vue3 system over the legacy scripts.

Key Components

ComfyApi (api.ts)

Main API client class that handles communication with the ComfyUI backend. Provides methods for:

  • Queue management
  • Model operations
  • Extension handling
  • WebSocket communication
  • User data management

ComfyApp (app.ts)

Core application class that manages:

  • Graph manipulation
  • Node management
  • Canvas interactions
  • Extension system
  • Workflow state

UI Components (ui/)

Collection of reusable UI components including:

  • Buttons and button groups
  • Popups and dialogs
  • Draggable lists
  • Image previews
  • Menu system
  • Settings dialog

Integration with Vite

All TypeScript exports are shimmed through Vite configuration to maintain compatibility with the legacy JavaScript codebase. The shimming logic can be found in vite.config.mts.

Legacy Compatibility

This codebase maintains compatibility with the original ComfyUI Legacy Frontend while providing TypeScript type safety and modern development features.

For users wanting to fall back to the legacy frontend, use the command line argument:

--front-end-version Comfy-Org/ComfyUI_legacy_frontend@latest