feat(collaboration): add Redis-backed Socket.IO session adapter - #1091
Merged
RUKAYAT-CODER merged 2 commits intoJul 26, 2026
Merged
Conversation
Contributor
|
Well done on the job so far! |
|
@JemimahEkong Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
Done
…On Sun, Jul 26, 2026 at 4:20 PM Rukayat Zakariyau ***@***.***> wrote:
*RUKAYAT-CODER* left a comment (rinafcode/teachLink_backend#1091)
<#1091 (comment)>
Well done on the job so far!
Kindly resolve conflict
—
Reply to this email directly, view it on GitHub
<#1091?email_source=notifications&email_token=BLUYM7QEBA465XFBWEL2JLD5GYOTRA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMBYGQYTAMRXGY42M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-5084102769>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BLUYM7XNMQYJH5RM4P4Y7YT5GYOTRAVCNFSNUABFKJSXA33TNF2G64TZHM4TKOJXG4ZTCMBSHNEXG43VMU5TIOJXHE3DSNZUGMY2C5QC>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/BLUYM7RQO3I2DRSRAWDEKPT5GYOTRA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMBYGQYTAMRXGY42M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KUZTPN52GK4S7NFXXG>
and Android
<https://github.com/notifications/mobile/android/BLUYM7WOCINF6UJOOXHUUPT5GYOTRA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTKMBYGQYTAMRXGY42M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2K4ZTPN52GK4S7MFXGI4TPNFSA>.
Download it today!
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Contributor
|
Thank you for contributing to the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #817
This PR replaces the collaboration module's in-memory WebSocket state with Redis-backed infrastructure, enabling reliable horizontal scaling across multiple Node.js instances while preserving existing Socket.IO behavior.
Previously, each application instance maintained isolated socket rooms and presence state, meaning users connected to different pods could not reliably receive collaboration updates or see accurate presence information.
What Changed
Socket.IO Redis Adapter
Updated
src/main.tsto integrate@socket.io/redis-adapter:maxHttpBufferSizeRedis Socket Registry
Added:
src/collaboration/redis-socket-registry.service.tsResponsibilities:
Stores socket ownership metadata in Redis
Maps:
socketId → sessionIdsocketId → userIdUses Redis hash storage:
collab:socket:{socketId}
TTL behavior:
Redis-Backed Presence Service (
src/collaboration/presence.service.ts)Migrated presence tracking from local memory to Redis hashes.
Changes:
Removed in-memory nested
MapstorageAdded Redis-backed operations using:
HSET
HDEL
HGETALL
HEXISTS
Updated presence methods to async operations
Enabled shared presence state across all application instances
This ensures users connected to different pods receive accurate membership updates.
Collaboration Gateway Updates (
src/collaboration/collaboration.gateway.ts)Updated gateway logic to use Redis-backed state.
Changes:
socketMapwithRedisSocketRegistryServiceOnGatewayConnectionlifecycle handlingRedis Data Model
collab:socket:{socketId}collab:presence:{sessionId}Why This Change
The previous collaboration architecture relied on process-local memory.
This caused issues for horizontally scaled deployments:
Redis-backed state provides a shared source of truth and allows the collaboration module to scale across multiple backend instances.
Testing
Validated with:
✅ 78 tests passing across 7 collaboration spec files
New and updated coverage includes:
Additional checks:
✅ Lint: 0 errors, 0 warnings
Build:
✅ No build issues introduced by this change
Note:
@redis/time-seriestype issue in the base branch remains unrelated to this PR.Limitations
Reviewer Notes
This PR introduces distributed collaboration infrastructure while keeping existing collaboration behavior unchanged.
Redis responsibilities are isolated into dedicated services, making the system easier to scale and providing a clean foundation for future persistence improvements.