fix(status): format disconnect reasons, demote incident publication logs, and guard pooled sockets

- Safely format Lavalink disconnect reason objects in Bot.mjs to avoid [object Object]
- Demote StatusChannelManager incident publication log from warn to info
- Suppress incident publication messages from ErrorChannel telemetry forwarding
- Verify Redis bridge readiness in StatusChannelManager dashboard probe when no HTTP port is configured
- Prevent duplicate error listeners on pooled keep-alive sockets in HttpStreams
This commit is contained in:
NoLogicAlan committed 2026-11-15 00:54:25 +03:00
1 parent 5e39679f45
commit 0c8349f44b
5 files changed
+50 -6

No files matched your search

+19 -1
View File
@@ -401,7 +401,25 @@ class Remix {
} }
}); });
this.lavalink.on("nodeDisconnect", (node, reason) => { this.lavalink.on("nodeDisconnect", (node, reason) => {
this.statusChannel?.triggerIncident("audioNode", `Audio engine disconnected: ${reason || "Connection dropped"}`); let reasonStr = "Connection dropped";
if (typeof reason === "string" && reason.trim()) {
reasonStr = reason.trim();
} else if (typeof reason === "object" && reason !== null) {
const text = reason.reason || reason.message;
const code = reason.code ? ` (code ${reason.code})` : "";
if (text) {
reasonStr = `${text}${code}`;
} else if (reason.code) {
reasonStr = `Socket closed (code ${reason.code})`;
} else {
try {
reasonStr = JSON.stringify(reason);
} catch (_) {
reasonStr = "Connection dropped";
}
}
}
this.statusChannel?.triggerIncident("audioNode", `Audio engine disconnected: ${reasonStr}`);
}); });
this.lavalink.on("nodeError", (node, err) => { this.lavalink.on("nodeError", (node, err) => {
this.statusChannel?.triggerIncident("audioNode", `Audio engine error: ${err?.message || "Unreachable"}`); this.statusChannel?.triggerIncident("audioNode", `Audio engine error: ${err?.message || "Unreachable"}`);
+2 -2
View File
@@ -290,8 +290,8 @@ function _forward(level, tag, args) {
const body = _formatArgs(args); const body = _formatArgs(args);
/* Suppress expected external not-found lookups from generating alarmist telemetry warnings */ /* Suppress expected external not-found lookups from generating alarmist telemetry warnings */
if (tag.includes("[LastFm]") && (/not found|error 6:/i.test(body) || /Track not found/i.test(body))) return; if (tag.includes("[LastFm]") && (/not found|error 6:/i.test(body) || /Track not found/i.test(body))) return;
/* Suppress transient socket drops from routine status channel updates */ /* Suppress status card incident publications and transient socket drops from creating telemetry warnings */
if (tag.includes("[StatusChannel]") && (/other side closed/i.test(body) || /fetch failed/i.test(body))) return; if (tag.includes("[StatusChannel]") && (/Incident published for/i.test(tag) || /Incident published for/i.test(body) || /other side closed/i.test(body) || /fetch failed/i.test(body))) return;
/* Suppress benign search fallback and candidate exploration warnings */ /* Suppress benign search fallback and candidate exploration warnings */
if (tag.includes("[Player]") && (/Free text search candidate/i.test(tag) || /search candidate.*failed/i.test(tag))) return; if (tag.includes("[Player]") && (/Free text search candidate/i.test(tag) || /search candidate.*failed/i.test(tag))) return;
const now = Date.now(); const now = Date.now();
+8
View File
@@ -171,6 +171,14 @@ export class RedisHandler {
}, 5000); }, 5000);
} }
/**
* Check whether Redis clients are connected and ready.
* @returns {boolean}
*/
isReady() {
return Boolean(!this._destroyed && this.client?.isReady);
}
/** /**
* Publish a message to a Redis channel. * Publish a message to a Redis channel.
* No-op if the handler is destroyed or the client is not ready. * No-op if the handler is destroyed or the client is not ready.
+6
View File
@@ -80,7 +80,10 @@ const HttpStreams = {
}); });
req.on("socket", (socket) => { req.on("socket", (socket) => {
if (!socket._hasRemixErrorHandler) {
socket._hasRemixErrorHandler = true;
socket.on("error", () => {}); socket.on("error", () => {});
}
}); });
req.on("error", reject); req.on("error", reject);
req.setTimeout(timeoutMs, () => { req.setTimeout(timeoutMs, () => {
@@ -170,7 +173,10 @@ const HttpStreams = {
}); });
req.on("socket", (socket) => { req.on("socket", (socket) => {
if (!socket._hasRemixErrorHandler) {
socket._hasRemixErrorHandler = true;
socket.on("error", () => {}); socket.on("error", () => {});
}
}); });
req.on("error", (err) => { req.on("error", (err) => {
+15 -3
View File
@@ -182,7 +182,7 @@ export class StatusChannelManager {
try { try {
await this._postMessage(payload); await this._postMessage(payload);
logger.warn(`[StatusChannel] Incident published for ${inc.name}: ${desc}`); logger.info(`[StatusChannel] Incident published for ${inc.name}: ${desc}`);
} catch (err) { } catch (err) {
logger.warn(`[StatusChannel] Failed to post incident for ${inc.name}:`, err?.message); logger.warn(`[StatusChannel] Failed to post incident for ${inc.name}:`, err?.message);
} }
@@ -394,8 +394,12 @@ export class StatusChannelManager {
const probe = async () => { const probe = async () => {
try { try {
const port = this.remix.dashboard?.port || 3000; const rawUrl = this.remix.config?.dashboard?.url;
const res = await fetch(`http://127.0.0.1:${port}/`, { const port = this.remix.config?.dashboard?.port || this.remix.dashboard?.port;
const targetUrl = rawUrl || (port ? `http://127.0.0.1:${port}/` : null);
if (targetUrl) {
const res = await fetch(targetUrl, {
signal: AbortSignal.timeout(4000), signal: AbortSignal.timeout(4000),
}); });
if (res.ok || res.status === 401 || res.status === 403 || res.status === 302) { if (res.ok || res.status === 401 || res.status === 403 || res.status === 302) {
@@ -403,6 +407,14 @@ export class StatusChannelManager {
} else { } else {
this.triggerIncident("dashboard", `Dashboard HTTP check returned status ${res.status}`); this.triggerIncident("dashboard", `Dashboard HTTP check returned status ${res.status}`);
} }
} else if (this.remix.dashboard?.redis) {
/* When dashboard runs as decoupled service via Redis pub/sub, verify Redis IPC */
if (typeof this.remix.dashboard.redis.isReady === "function" && this.remix.dashboard.redis.isReady()) {
this.resolveIncident("dashboard");
} else {
this.triggerIncident("dashboard", "Dashboard Redis bridge disconnected");
}
}
} catch (err) { } catch (err) {
this.triggerIncident("dashboard", `Dashboard is unreachable (${err?.message})`); this.triggerIncident("dashboard", `Dashboard is unreachable (${err?.message})`);
} }