From 0cd2a2b9d1ba17498c99a19d32fe52d505f801ad Mon Sep 17 00:00:00 2001 From: Julian Pufler Date: Tue, 14 Jan 2025 18:16:21 +0100 Subject: [PATCH] fix(core): Run delete query directly for sessions --- .../core/src/service/services/session.service.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/core/src/service/services/session.service.ts b/packages/core/src/service/services/session.service.ts index c919e9f9b9..64a706b4c8 100644 --- a/packages/core/src/service/services/session.service.ts +++ b/packages/core/src/service/services/session.service.ts @@ -322,18 +322,13 @@ export class SessionService implements EntitySubscriberInterface { */ async cleanupExpiredSessions(ctx: RequestContext): Promise { const now = new Date(); - const sessions = await this.connection + + await this.connection .getRepository(ctx, Session) .createQueryBuilder('session') - .select('session.id') .where('session.expires <= :now', { now }) - .getMany(); - - await this.connection.getRepository(ctx, Session).remove(sessions, { chunk: 500 }); - - for (const session of sessions) { - await this.withTimeout(this.sessionCacheStrategy.delete(session.token)); - } + .delete() + .execute(); } /**