From 46cf55128101a45dfce58b3d578846958ed614ea Mon Sep 17 00:00:00 2001 From: Paul Rastoin <45004772+prastoin@users.noreply.github.com> Date: Tue, 13 Jan 2026 17:07:27 +0100 Subject: [PATCH] Invalidate legacy cache after flats (#17126) # Introduction Some legacy caches are based on the flat ones So we need to seq invalidate before invalidating others as it could result in inter dep cache invalidation race condition --- .../workspace-migration-runner.service.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service.ts index 072e0e0256..875b3ed4a0 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-migration/workspace-migration-runner/services/workspace-migration-runner.service.ts @@ -180,18 +180,19 @@ export class WorkspaceMigrationRunnerService { `Cache invalidation ${flatEntitiesCacheToInvalidate.join()}`, ); - const invalidationResults = await Promise.allSettled([ - this.flatEntityMapsCacheService.invalidateFlatEntityMaps({ - workspaceId, - flatMapsKeys: flatEntitiesCacheToInvalidate, - }), - ...this.getLegacyCacheInvalidationPromises({ + await this.flatEntityMapsCacheService.invalidateFlatEntityMaps({ + workspaceId, + flatMapsKeys: flatEntitiesCacheToInvalidate, + }); + + const invalidationResults = await Promise.allSettled( + this.getLegacyCacheInvalidationPromises({ workspaceMigration: { actions, workspaceId, }, }), - ]); + ); const invalidationFailures = invalidationResults.filter( (result) => result.status === 'rejected',