Skip to content

Commit

Permalink
regression: do not update logged out sessions (#35041)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego authored Jan 27, 2025
1 parent 2387725 commit db58b23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion apps/meteor/app/statistics/server/lib/SAUMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const getUserRoles = mem(
{ maxAge: 5000 },
);

const isProdEnv = process.env.NODE_ENV === 'production';

/**
* Server Session Monitor for SAU(Simultaneously Active Users) based on Meteor server sessions
*/
Expand Down Expand Up @@ -143,7 +145,11 @@ export class SAUMonitorClass {
projection: { loginToken: 1 },
});
if (!session?.loginToken) {
throw new Error('Session not found');
if (!isProdEnv) {
throw new Error('Session not found during logout');
}
logger.error('Session not found during logout', { userId, sessionId });
return;
}

await Sessions.logoutBySessionIdAndUserId({ loginToken: session.loginToken, userId });
Expand Down
4 changes: 3 additions & 1 deletion packages/models/src/models/Sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1442,8 +1442,10 @@ export class SessionsRaw extends BaseRaw<ISession> implements ISessionsModel {

const now = new Date();

const query = { instanceId, sessionId, year, month, day, logoutAt: { $exists: false } };

return this.updateOne(
{ instanceId, sessionId, year, month, day },
query,
{
$set: data,
$setOnInsert: {
Expand Down

0 comments on commit db58b23

Please sign in to comment.