fix: drop all over-limit messages and clear rate-limit flag on recovery#546
Open
xpoes123 wants to merge 1 commit into
Open
fix: drop all over-limit messages and clear rate-limit flag on recovery#546xpoes123 wants to merge 1 commit into
xpoes123 wants to merge 1 commit into
Conversation
…ged until restart Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes two bugs in the multiplayer rate-limiter: flagged users' subsequent over-limit messages were no longer being dropped, and the flag was never cleared even after a user returned under the limit.
Problem
In
server/multiplayer/ServerMultiplayerRoomMixin.js(around line 120), the guard condition was:This had two defects:
usernamewas inrateLimitExceeded, the condition!this.rateLimitExceeded.has(username)becamefalse, so the entire guard evaluated tofalseand thereturnwas never reached. Subsequent over-limit messages from that user were processed rather than dropped.rateLimitExceededwas only ever added to, never cleaned up. A user who briefly exceeded the limit and then went quiet remained flagged for the entire room lifetime, affecting future legitimate messages after a cooldown.Changes
returnunconditionally wheneverthis.rateLimiter(socket)is truthy, dropping every over-limit message.rateLimitExceededonly to suppress duplicate log lines within a burst (log once, not once per message).this.rateLimitExceeded.delete(username)on the non-rate-limited path so a user recovers automatically once their message rate falls back under the limit.Risk & testing
Logic-only change; no new dependencies. The anti-spam behavior is strictly strengthened — legitimate messages in a new interval are unaffected. Verified by reading the
rateLimitercontract: it returns truthy while the socket is over limit and falsy once the interval resets.node --checkpasses.