Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle invalid node def errors #1340

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions browser_tests/interaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ test.describe('Node Interaction', () => {
await comfyPage.disconnectEdge()
await expect(comfyPage.canvas).toHaveScreenshot('disconnected-edge.png')
await comfyPage.connectEdge()
// Move mouse to empty area to avoid slot highlight.
await comfyPage.moveMouseToEmptyArea()
// Litegraph renders edge with a slight offset.
await expect(comfyPage.canvas).toHaveScreenshot('default.png', {
maxDiffPixels: 50
Expand Down
16 changes: 11 additions & 5 deletions src/stores/nodeDefStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,18 @@ export const useNodeDefStore = defineStore('nodeDef', () => {
const nodeTree = computed(() => buildNodeDefTree(visibleNodeDefs.value))

function updateNodeDefs(nodeDefs: ComfyNodeDef[]) {
const newNodeDefsByName: { [key: string]: ComfyNodeDefImpl } = {}
const newNodeDefsByDisplayName: { [key: string]: ComfyNodeDefImpl } = {}
const newNodeDefsByName: Record<string, ComfyNodeDefImpl> = {}
const newNodeDefsByDisplayName: Record<string, ComfyNodeDefImpl> = {}
for (const nodeDef of nodeDefs) {
const nodeDefImpl = new ComfyNodeDefImpl(nodeDef)
newNodeDefsByName[nodeDef.name] = nodeDefImpl
newNodeDefsByDisplayName[nodeDef.display_name] = nodeDefImpl
try {
const nodeDefImpl = new ComfyNodeDefImpl(nodeDef)
newNodeDefsByName[nodeDef.name] = nodeDefImpl
newNodeDefsByDisplayName[nodeDef.display_name] = nodeDefImpl
} catch (e) {
// Avoid breaking the app for invalid nodeDefs
// NodeDef validation is now optional for performance reasons
console.error('Error adding nodeDef:', e)
}
}
nodeDefsByName.value = newNodeDefsByName
nodeDefsByDisplayName.value = newNodeDefsByDisplayName
Expand Down
Loading