Skip to content

fix: add cleanup(ip) to connRateLimiter to prevent memory leak - #206

Merged
levibliz merged 1 commit into
RiftCore00:devfrom
rilwanubala:fix/conn-rate-limiter-cleanup
Jul 28, 2026
Merged

fix: add cleanup(ip) to connRateLimiter to prevent memory leak#206
levibliz merged 1 commit into
RiftCore00:devfrom
rilwanubala:fix/conn-rate-limiter-cleanup

Conversation

@rilwanubala

Copy link
Copy Markdown
Contributor

Every unique IP that connected created a windows Map entry that was never deleted, causing unbounded memory growth in long-running deployments with frequently changing mobile IPs.
Closes #169

  • Add cleanup(ip) method to createConnRateLimiter that deletes the IP's entry from the windows Map
  • Call connRateLimiter.cleanup(ws._trackedIp) in the ws close handler in server.js inside the existing trackedIp guard
  • Add unit tests asserting fresh window after cleanup, no-op for unknown IPs, and that cleanup does not throw

Fixes memory leak in conn-rate-limiter windows Map.

Every unique IP that connected created a windows Map entry that was
never deleted, causing unbounded memory growth in long-running
deployments with frequently changing mobile IPs.

- Add cleanup(ip) method to createConnRateLimiter that deletes the
  IP's entry from the windows Map
- Call connRateLimiter.cleanup(ws._trackedIp) in the ws close handler
  in server.js inside the existing trackedIp guard
- Add unit tests asserting fresh window after cleanup, no-op for
  unknown IPs, and that cleanup does not throw

Fixes memory leak in conn-rate-limiter windows Map.
@levibliz
levibliz merged commit 3405b1d into RiftCore00:dev Jul 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

conn-rate-limiter: add cleanup(ip) method to prevent unbounded memory growth

2 participants