fix(server): cap reactionsStore at 1000 entries to prevent memory exhaustion [NSoC'26]#144
Open
anshul23102 wants to merge 1 commit into
Open
fix(server): cap reactionsStore at 1000 entries to prevent memory exhaustion [NSoC'26]#144anshul23102 wants to merge 1 commit into
anshul23102 wants to merge 1 commit into
Conversation
…memory growth [NSoC'26] reactionsStore was a plain object with no size cap or eviction policy. Every unique messageId added a permanent entry. A user who sent many messages or reacted to many unique message IDs could grow the object without limit, eventually exhausting process heap. Added MAX_REACTION_ENTRIES = 1000. When a new messageId arrives and the store is already at capacity, the oldest key is deleted before inserting the new entry. This keeps memory bounded without affecting reactions on recently active messages. Closes Shriii19#139
|
@anshul23102 is attempting to deploy a commit to the shreemp194-gmailcom's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
👋 Thank you for opening this pull request! I will review your changes and assist you soon. |
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.
Description
reactionsStorewas a plain object with no size cap or eviction policy. Every uniquemessageIdadded a permanent entry. Over time, as messages accumulated and reactions were added to many distinct message IDs, the store grew without limit. A user who sent many messages or triggered reactions on many unique IDs could exhaust process heap memory.Related Issue
Closes #139
Type of Change
Root Cause
const reactionsStore = {}had no maximum entry count and no eviction logic. Entries were never deleted, even after their cooldown window long passed.Changes Made
backend/server.jsMAX_REACTION_ENTRIES = 1000constant with explanatory commentbackend/server.js"react"handler: before inserting a newmessageId, if the store is at capacity the oldest key is deleted firstScreenshots or Demo
Not applicable (backend-only change).
Testing Done
Object.keys(reactionsStore).lengthat 1000.Checklist
NSoC Label Request
@Shriii19 could you please add the appropriate NSoC '26 label to this PR? Thank you!