mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-24 15:00:45 +03:00
Fix duplicated calculation of nodes and dependent nodes are not initialized
This commit is contained in:
@@ -298,7 +298,9 @@ export const buildFlow = async (
|
||||
nodeQueue.push({ nodeId: startingNodeIds[i], depth: 0 })
|
||||
exploredNode[startingNodeIds[i]] = { remainingLoop: maxLoop, lastSeenDepth: 0 }
|
||||
}
|
||||
|
||||
|
||||
const initializedNode: Set<string> = new Set()
|
||||
const nonDirectedGraph = constructGraphs(reactFlowNodes, reactFlowEdges, { isReversed: true }).graph
|
||||
while (nodeQueue.length) {
|
||||
const { nodeId, depth } = nodeQueue.shift() as INodeQueue
|
||||
|
||||
@@ -384,6 +386,7 @@ export const buildFlow = async (
|
||||
flowNodes[nodeIndex].data.instance = outputResult
|
||||
|
||||
logger.debug(`[server]: Finished initializing ${reactFlowNode.data.label} (${reactFlowNode.data.id})`)
|
||||
initializedNode.add(reactFlowNode.data.id)
|
||||
}
|
||||
} catch (e: any) {
|
||||
logger.error(e)
|
||||
@@ -406,6 +409,8 @@ export const buildFlow = async (
|
||||
for (let i = 0; i < neighbourNodeIds.length; i += 1) {
|
||||
const neighNodeId = neighbourNodeIds[i]
|
||||
if (ignoreNodeIds.includes(neighNodeId)) continue
|
||||
if (initializedNode.has(neighNodeId)) continue
|
||||
if (nonDirectedGraph[neighNodeId].some((dependId) => !initializedNode.has(dependId))) continue
|
||||
// If nodeId has been seen, cycle detected
|
||||
if (Object.prototype.hasOwnProperty.call(exploredNode, neighNodeId)) {
|
||||
const { remainingLoop, lastSeenDepth } = exploredNode[neighNodeId]
|
||||
|
||||
Reference in New Issue
Block a user