From db12ce95a8be94e5746dc63f093daeef4b8784d9 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Thu, 14 Mar 2024 10:20:23 +1100 Subject: [PATCH] fix(ui): invalid collect node error w/ control adapters The graph builders used awaited functions within `Array.prototype.forEach` loops. This doesn't do what you'd think. This caused graphs to be enqueued before they were fully constructed. Changed to `for..of` loops to fix this. --- .../features/nodes/util/graph/addControlNetToLinearGraph.ts | 4 ++-- .../features/nodes/util/graph/addIPAdapterToLinearGraph.ts | 4 ++-- .../features/nodes/util/graph/addT2IAdapterToLinearGraph.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/addControlNetToLinearGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graph/addControlNetToLinearGraph.ts index b5dad9e080..834dda4565 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graph/addControlNetToLinearGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graph/addControlNetToLinearGraph.ts @@ -49,7 +49,7 @@ export const addControlNetToLinearGraph = async ( }, }); - validControlNets.forEach(async (controlNet) => { + for (const controlNet of validControlNets) { if (!controlNet.model) { return; } @@ -114,7 +114,7 @@ export const addControlNetToLinearGraph = async ( field: 'item', }, }); - }); + } upsertMetadata(graph, { controlnets: controlNetMetadata }); } }; diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/addIPAdapterToLinearGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graph/addIPAdapterToLinearGraph.ts index a76265f69a..7a1fb3266f 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graph/addIPAdapterToLinearGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graph/addIPAdapterToLinearGraph.ts @@ -42,7 +42,7 @@ export const addIPAdapterToLinearGraph = async ( const ipAdapterMetdata: CoreMetadataInvocation['ipAdapters'] = []; - validIPAdapters.forEach(async (ipAdapter) => { + for (const ipAdapter of validIPAdapters) { if (!ipAdapter.model) { return; } @@ -84,7 +84,7 @@ export const addIPAdapterToLinearGraph = async ( field: 'item', }, }); - }); + } upsertMetadata(graph, { ipAdapters: ipAdapterMetdata }); } diff --git a/invokeai/frontend/web/src/features/nodes/util/graph/addT2IAdapterToLinearGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graph/addT2IAdapterToLinearGraph.ts index 91a4beded7..9763dda268 100644 --- a/invokeai/frontend/web/src/features/nodes/util/graph/addT2IAdapterToLinearGraph.ts +++ b/invokeai/frontend/web/src/features/nodes/util/graph/addT2IAdapterToLinearGraph.ts @@ -45,7 +45,7 @@ export const addT2IAdaptersToLinearGraph = async ( const t2iAdapterMetadata: CoreMetadataInvocation['t2iAdapters'] = []; - validT2IAdapters.forEach(async (t2iAdapter) => { + for (const t2iAdapter of validT2IAdapters) { if (!t2iAdapter.model) { return; } @@ -107,7 +107,7 @@ export const addT2IAdaptersToLinearGraph = async ( field: 'item', }, }); - }); + } upsertMetadata(graph, { t2iAdapters: t2iAdapterMetadata }); }