Skip to content

Commit

Permalink
fix(core): Run delete query directly for sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
pujux committed Jan 14, 2025
1 parent 55883df commit 0cd2a2b
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions packages/core/src/service/services/session.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,18 +322,13 @@ export class SessionService implements EntitySubscriberInterface {
*/
async cleanupExpiredSessions(ctx: RequestContext): Promise<void> {
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();
}

/**
Expand Down

0 comments on commit 0cd2a2b

Please sign in to comment.