Skip to content

Commit d7e9fa3

Browse files
committed
fix glasses grace period handling
1 parent 42aff7f commit d7e9fa3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

augmentos_cloud/packages/cloud/src/services/websocket/websocket-glasses.service.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,15 @@ export class GlassesWebSocketService {
482482
userSession.cleanupTimerId = setTimeout(() => {
483483
userSession.logger.info({ service: SERVICE_NAME }, `Cleanup grace period expired for user session: ${userSession.userId}`);
484484

485+
// Check to see if the session has reconnected / if the user is still active.
486+
if (userSession.websocket && userSession.websocket.readyState === WebSocket.OPEN) {
487+
userSession.logger.info({ service: SERVICE_NAME }, `User session ${userSession.userId} has reconnected, skipping cleanup.`);
488+
clearTimeout(userSession.cleanupTimerId!);
489+
userSession.cleanupTimerId = undefined;
490+
return;
491+
}
492+
493+
userSession.logger.info({ service: SERVICE_NAME }, `User session ${userSession.userId} has not reconnected, cleaning up session.`);
485494
// End the session
486495
sessionService.endSession(userSession);
487496
}, RECONNECT_GRACE_PERIOD_MS);

0 commit comments

Comments
 (0)