(hotfix)cleaning up

This commit is contained in:
NoLogicAlan committed 2026-05-14 20:08:10 +03:00
1 parent 3c14f04756
commit 7096602d9c
9 files changed
+44 -1097

No files matched your search

+11 -16
View File
@@ -194,10 +194,9 @@ export class FluxerRevoice extends EventEmitter {
/** @type {number} Minimum delay between ANY two joins (ms), even across guilds.
* This delay runs AFTER the previous join completes and BEFORE the next
* one starts, giving the Fluxer gateway time to clean up the previous
* voice session. 3 seconds is needed because the gateway's Erlang backend
* needs time to process the voice state transition before a new join
* can succeed without 401 errors. */
_globalJoinDelay = 3_000;
* voice session. 500ms is sufficient; the per-guild _guildMinJoinInterval
* provides additional safety for rapid same-guild rejoins. */
_globalJoinDelay = 500;
/** @type {Set<string>} Channel IDs where disconnect is expected (bot-initiated) */
_intentionalDisconnects = new Set();
@@ -211,12 +210,9 @@ export class FluxerRevoice extends EventEmitter {
/** @type {number} Minimum time between guild joins (ms) — enforced on top of
* the per-join delay. If a new join is requested within this window, we
* wait the remaining time before proceeding. Increased from 7000 to 8000
* because 7000ms was insufficient to prevent 401 errors when the bot
* re-joins a channel in the same guild quickly after a disconnect,
* especially during boot recovery when multiple guilds compete for
* gateway attention. */
_guildMinJoinInterval = 8000;
* wait the remaining time before proceeding. 2s is enough with the global
* join queue providing additional serialization. */
_guildMinJoinInterval = 2000;
/** @type {Map<string, number>} Guild IDs that recently had a 401 error.
* Used to add an even longer backoff before retrying joins in that guild. */
@@ -391,9 +387,8 @@ export class FluxerRevoice extends EventEmitter {
try { existing.removeAllListeners(); } catch (_) {}
// 4. Brief delay to let the gateway process the leave before we rejoin.
// Increased from 1500ms to 2000ms to give the Erlang gateway backend
// more time to clean up the previous voice session.
await new Promise(r => setTimeout(r, 2000));
// 250ms is enough since the join() operation itself adds _globalJoinDelay.
await new Promise(r => setTimeout(r, 250));
}
/**
@@ -558,11 +553,11 @@ export class FluxerRevoice extends EventEmitter {
if (e.message?.includes("401") || e.message?.includes("Unauthorized")) {
const gId = channelGuildId ?? this._resolveGuildForChannel(channelId);
if (gId) {
// Set 45-second cooldown for this guild to prevent rapid 401 retries
this._guild401Cooldown.set(gId, Date.now() + 45_000);
// Set 15-second cooldown for this guild to prevent rapid 401 retries
this._guild401Cooldown.set(gId, Date.now() + 15_000);
logger.warn(
`[FluxerRevoice] 401 error for channel ${channelId} — ` +
`setting 45s cooldown for guild ${gId}`
`setting 15s cooldown for guild ${gId}`
);
}
}