mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
no more leaks
This commit is contained in:
1 parent
9565d9f037
commit
4dea723a3d
3 files changed
+262
-50
No files matched your search
@@ -718,8 +718,14 @@ class Remix {
|
||||
const prev = _prevVoiceState.get(userId);
|
||||
const oldChannelId = prev?.channelId ?? null;
|
||||
|
||||
// Update prev state
|
||||
// Update prev state — evict oldest entry if Map exceeds 10,000 entries
|
||||
// (one per user who has ever touched voice since last restart) to prevent
|
||||
// unbounded growth on large bots that never restart.
|
||||
if (channelId) {
|
||||
if (_prevVoiceState.size >= 10_000 && !_prevVoiceState.has(userId)) {
|
||||
// Remove the oldest inserted entry (Maps preserve insertion order)
|
||||
_prevVoiceState.delete(_prevVoiceState.keys().next().value);
|
||||
}
|
||||
_prevVoiceState.set(userId, { channelId, guildId });
|
||||
} else {
|
||||
_prevVoiceState.delete(userId);
|
||||
|
||||
Reference in new issue
Block a user