From 2257ec63b3716598f85a5237bc147bb2c887fa33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Tue, 23 Jan 2024 12:34:40 +0100 Subject: [PATCH] fix(core): Fix removal of triggers and pollers from memory on deactivation in multi-main setup (#8416) --- packages/core/src/ActiveWorkflows.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/core/src/ActiveWorkflows.ts b/packages/core/src/ActiveWorkflows.ts index f331166fe4447..bcc5bb285be6b 100644 --- a/packages/core/src/ActiveWorkflows.ts +++ b/packages/core/src/ActiveWorkflows.ts @@ -209,8 +209,13 @@ export class ActiveWorkflows { const w = this.activeWorkflows[workflowId]; - w.triggerResponses?.forEach(async (r) => await this.close(r, workflowId, 'trigger')); - w.pollResponses?.forEach(async (r) => await this.close(r, workflowId, 'poller')); + for (const r of w.triggerResponses ?? []) { + await this.close(r, workflowId, 'trigger'); + } + + for (const r of w.pollResponses ?? []) { + await this.close(r, workflowId, 'poller'); + } delete this.activeWorkflows[workflowId]; @@ -219,10 +224,7 @@ export class ActiveWorkflows { async removeAllTriggerAndPollerBasedWorkflows() { for (const workflowId of Object.keys(this.activeWorkflows)) { - const w = this.activeWorkflows[workflowId]; - - w.triggerResponses?.forEach(async (r) => await this.close(r, workflowId, 'trigger')); - w.pollResponses?.forEach(async (r) => await this.close(r, workflowId, 'poller')); + await this.remove(workflowId); } }