From 86bbe62abeeb14cccd761a1a1b6536d14689243c Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Mon, 13 Jan 2025 14:36:34 +0200 Subject: [PATCH] fix: remove archived features from delta (#9088) Weird thing is that I could not reproduce it locally, but I have a theory to fix our delta mismatch. Revisions are added to the delta every second. This means that in a single revision, you can disable an event, remove a dependency, and archive it simultaneously. These actions are usually performed together since archiving an event will inherently disable it, remove its dependencies, and so on. Currently, we observe these events happening within the same revision. However, since we were checking `.updated` last, the event was always removed from the `removedMap`. Now, by checking `.removed` last, the archive action will properly propagate to the revision. --- .../delta/client-feature-toggle-delta.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.ts b/src/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.ts index 38234ea1df..1f8c03be99 100644 --- a/src/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.ts +++ b/src/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.ts @@ -53,14 +53,14 @@ const applyRevision = (first: Revision, last: Revision): Revision => { ]), ); - for (const feature of last.removed) { - updatedMap.delete(feature.name); - } - for (const feature of last.updated) { removedMap.delete(feature.name); } + for (const feature of last.removed) { + updatedMap.delete(feature.name); + } + return { revisionId: last.revisionId, updated: Array.from(updatedMap.values()),