diff --git a/packages/twenty-server/src/engine/subscriptions/event-stream.service.ts b/packages/twenty-server/src/engine/subscriptions/event-stream.service.ts index 5dbe44d9f0..d043d255b5 100644 --- a/packages/twenty-server/src/engine/subscriptions/event-stream.service.ts +++ b/packages/twenty-server/src/engine/subscriptions/event-stream.service.ts @@ -3,7 +3,6 @@ import { Injectable, Logger, OnModuleInit } from '@nestjs/common'; import { isDefined } from 'twenty-shared/utils'; import { type SerializableAuthContext } from 'src/engine/core-modules/auth/types/serializable-auth-context.type'; -import { CacheLockService } from 'src/engine/core-modules/cache-lock/cache-lock.service'; import { WithLock } from 'src/engine/core-modules/cache-lock/with-lock.decorator'; import { InjectCacheStorage } from 'src/engine/core-modules/cache-storage/decorators/cache-storage.decorator'; import { CacheStorageService } from 'src/engine/core-modules/cache-storage/services/cache-storage.service'; @@ -30,7 +29,6 @@ export class EventStreamService implements OnModuleInit { constructor( @InjectCacheStorage(CacheStorageNamespace.EngineSubscriptions) private readonly cacheStorageService: CacheStorageService, - private readonly cacheLockService: CacheLockService, private readonly metricsService: MetricsService, ) {} @@ -90,15 +88,11 @@ export class EventStreamService implements OnModuleInit { await this.cacheStorageService.set(key, streamData, EVENT_STREAM_TTL_MS); - const activeStreamsKey = this.getActiveStreamsKey(workspaceId); - - await this.cacheLockService.withLock(async () => { - await this.cacheStorageService.setAdd( - activeStreamsKey, - [eventStreamChannelId], - EVENT_STREAM_TTL_MS, - ); - }, activeStreamsKey); + await this.cacheStorageService.setAdd( + this.getActiveStreamsKey(workspaceId), + [eventStreamChannelId], + EVENT_STREAM_TTL_MS, + ); } async destroyEventStream({ @@ -112,13 +106,10 @@ export class EventStreamService implements OnModuleInit { await this.cacheStorageService.del(key); - const activeStreamsKey = this.getActiveStreamsKey(workspaceId); - - await this.cacheLockService.withLock(async () => { - await this.cacheStorageService.setRemove(activeStreamsKey, [ - eventStreamChannelId, - ]); - }, activeStreamsKey); + await this.cacheStorageService.setRemove( + this.getActiveStreamsKey(workspaceId), + [eventStreamChannelId], + ); } async getActiveStreamIds(workspaceId: string): Promise { @@ -135,14 +126,10 @@ export class EventStreamService implements OnModuleInit { return; } - const activeStreamsKey = this.getActiveStreamsKey(workspaceId); - - await this.cacheLockService.withLock(async () => { - await this.cacheStorageService.setRemove( - activeStreamsKey, - streamIdsToRemove, - ); - }, activeStreamsKey); + await this.cacheStorageService.setRemove( + this.getActiveStreamsKey(workspaceId), + streamIdsToRemove, + ); } async getStreamsData(