فهرست منبع

fix(core): Fix error with new session cache when seeding data

Michael Bromley 1 سال پیش
والد
کامیت
508f797e82
1فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  1. 6 1
      packages/core/src/config/session-cache/default-session-cache-strategy.ts

+ 6 - 1
packages/core/src/config/session-cache/default-session-cache-strategy.ts

@@ -47,7 +47,12 @@ export class DefaultSessionCacheStrategy implements SessionCacheStrategy {
     }
     }
 
 
     clear(): Promise<void> {
     clear(): Promise<void> {
-        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);
     }
     }
 
 
     /**
     /**