From 6ff736e28a54d41d57cd496c720b6871b112feb0 Mon Sep 17 00:00:00 2001 From: Chris Berry Date: Mon, 8 Jul 2019 09:15:55 -0700 Subject: [PATCH] fix(core): consider stage count when hydrating executions (#7194) --- .../modules/core/src/pipeline/service/execution.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/scripts/modules/core/src/pipeline/service/execution.service.ts b/app/scripts/modules/core/src/pipeline/service/execution.service.ts index 3315b7f0ef8..afe586f3482 100644 --- a/app/scripts/modules/core/src/pipeline/service/execution.service.ts +++ b/app/scripts/modules/core/src/pipeline/service/execution.service.ts @@ -499,7 +499,9 @@ export class ExecutionService { // stages *should* be in the same order, so getting the hydrated one by index should be fine. // worth verifying, though, and, if not, find the stage by id (which makes this an O(n^2) operation instead of O(n)) const hydratedStage = - hydrated.stages[i].id === s.id ? hydrated.stages[i] : hydrated.stages.find(s2 => s.id === s2.id); + hydrated.stages.length === unhydrated.stages.length && hydrated.stages[i].id === s.id + ? hydrated.stages[i] + : hydrated.stages.find(s2 => s.id === s2.id); if (hydratedStage) { s.context = hydratedStage.context; s.outputs = hydratedStage.outputs;