Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading