Skip to content

Commit db58b23

Browse files
authored
regression: do not update logged out sessions (#35041)
1 parent 2387725 commit db58b23

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

apps/meteor/app/statistics/server/lib/SAUMonitor.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const getUserRoles = mem(
3030
{ maxAge: 5000 },
3131
);
3232

33+
const isProdEnv = process.env.NODE_ENV === 'production';
34+
3335
/**
3436
* Server Session Monitor for SAU(Simultaneously Active Users) based on Meteor server sessions
3537
*/
@@ -143,7 +145,11 @@ export class SAUMonitorClass {
143145
projection: { loginToken: 1 },
144146
});
145147
if (!session?.loginToken) {
146-
throw new Error('Session not found');
148+
if (!isProdEnv) {
149+
throw new Error('Session not found during logout');
150+
}
151+
logger.error('Session not found during logout', { userId, sessionId });
152+
return;
147153
}
148154

149155
await Sessions.logoutBySessionIdAndUserId({ loginToken: session.loginToken, userId });

packages/models/src/models/Sessions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,8 +1442,10 @@ export class SessionsRaw extends BaseRaw<ISession> implements ISessionsModel {
14421442

14431443
const now = new Date();
14441444

1445+
const query = { instanceId, sessionId, year, month, day, logoutAt: { $exists: false } };
1446+
14451447
return this.updateOne(
1446-
{ instanceId, sessionId, year, month, day },
1448+
query,
14471449
{
14481450
$set: data,
14491451
$setOnInsert: {

0 commit comments

Comments
 (0)