RocketChat / RocketChat/Rocket.Chat
Optimizing login-token invalidation by emitting dedicated events
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description:
Login tokin invalidation currently goes through the generic 'watch.users' updates (via services.resume.loginTokens), instead of a dedicated event/channel for session changes.
Because of this, services that only care about login token changes must subscribe to broad user update traffic and filter every watch.users event. This creates unnecessary fan out and avoidable processing overhead.
Steps to reproduce:
- Trigger flows that remove login tokens (e.g. enable 2FA, logout other clients, logout).
- Observe emitted internal events.
- Confirm login token changes are broadcast through
watch.usersuser diffs.
Expected behavior:
- Login token/session invalidation should be emitted through a dedicated internal event (session-focused).
- Consumers interested only in token/session updates should subscribe to that targeted event.
watch.usersshould remain focused on generic user profile/state updates.
Actual behavior:
- Login token changes are sent through
watch.users. - Consumers that only need session/token updates are forced to listen to all user change events and filter manually.
Additional context
Related TODO comments are present in multiple places indicating this optimization opportunity
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing services.resume.loginTokens and the watch.users event path, including the locations with the related TODO comments. Review the flows for 2FA, logout of other clients, and logout, then identify the consumers that depend on these updates. Done means session or login-token invalidation has a targeted internal event while watch.users remains for generic user changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authentication, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100