From 508f797e82e25daae41b6a4850954307657381f0 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Thu, 31 Oct 2024 09:56:05 +0100 Subject: [PATCH] fix(core): Fix error with new session cache when seeding data --- .../config/session-cache/default-session-cache-strategy.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/src/config/session-cache/default-session-cache-strategy.ts b/packages/core/src/config/session-cache/default-session-cache-strategy.ts index a6a4e24166..0fe5e17286 100644 --- a/packages/core/src/config/session-cache/default-session-cache-strategy.ts +++ b/packages/core/src/config/session-cache/default-session-cache-strategy.ts @@ -47,7 +47,12 @@ export class DefaultSessionCacheStrategy implements SessionCacheStrategy { } clear(): Promise { - return this.cacheService.invalidateTags(this.tags); + // We use the `?` here because there is a case where in the SessionService, + // the clearSessionCacheOnDataChange() method may be invoked during bootstrap prior to + // the cacheService being initialized in the `init()` method above. + // This is an edge-case limited to seeding initial data as in e2e tests or a + // @vendure/create installation, so it is safe to not invalidate the cache in this case. + return this.cacheService?.invalidateTags(this.tags); } /**