From e3e0f91e6e43d05bfe3eb8f4b3e975385aafbc50 Mon Sep 17 00:00:00 2001 From: NagendraOpsmx <80510611+NagendraOpsmx@users.noreply.github.com> Date: Thu, 19 Sep 2024 10:59:42 +0530 Subject: [PATCH] Spin UI is becoming unresponsive if we click on pipeline configuration (#97) --- .../config/services/PipelineConfigService.ts | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/core/src/pipeline/config/services/PipelineConfigService.ts b/packages/core/src/pipeline/config/services/PipelineConfigService.ts index 7182ff9caee..7ef7bce6988 100644 --- a/packages/core/src/pipeline/config/services/PipelineConfigService.ts +++ b/packages/core/src/pipeline/config/services/PipelineConfigService.ts @@ -165,16 +165,22 @@ export class PipelineConfigService { if (!map || !stage) { return []; } - let downstreamStages: Array = []; - - const children = map.get(stage); - if (children && children.length) { - downstreamStages = downstreamStages.concat(children); - children.forEach((child) => { - downstreamStages = downstreamStages.concat(PipelineConfigService.getDownstreamStageIds(map, child)); - }); + const downstreamStages = new Set(); + const pipeStages = [stage]; + + while (pipeStages.length > 0) { + const currentStage = pipeStages.pop(); + const children = currentStage ? map.get(currentStage) : null; + if (children) { + for (const child of children) { + if (!downstreamStages.has(child)) { + downstreamStages.add(child); + pipeStages.push(child); + } + } + } } - return uniq(downstreamStages); + return Array.from(downstreamStages); } public static getDependencyCandidateStages(pipeline: IPipeline, stage: IStage): IStage[] {