diff --git a/src/core/Bot.mjs b/src/core/Bot.mjs index 74fc8db..1825357 100644 --- a/src/core/Bot.mjs +++ b/src/core/Bot.mjs @@ -401,7 +401,25 @@ class Remix { } }); 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.statusChannel?.triggerIncident("audioNode", `Audio engine error: ${err?.message || "Unreachable"}`); diff --git a/src/core/ErrorChannel.mjs b/src/core/ErrorChannel.mjs index 24b521a..e6def98 100644 --- a/src/core/ErrorChannel.mjs +++ b/src/core/ErrorChannel.mjs @@ -290,8 +290,8 @@ function _forward(level, tag, args) { const body = _formatArgs(args); /* 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; - /* Suppress transient socket drops from routine status channel updates */ - if (tag.includes("[StatusChannel]") && (/other side closed/i.test(body) || /fetch failed/i.test(body))) return; + /* Suppress status card incident publications and transient socket drops from creating telemetry warnings */ + 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 */ if (tag.includes("[Player]") && (/Free text search candidate/i.test(tag) || /search candidate.*failed/i.test(tag))) return; const now = Date.now(); diff --git a/src/dashboard/RedisHandler.mjs b/src/dashboard/RedisHandler.mjs index 0da6a77..b12c23a 100644 --- a/src/dashboard/RedisHandler.mjs +++ b/src/dashboard/RedisHandler.mjs @@ -171,6 +171,14 @@ export class RedisHandler { }, 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. * No-op if the handler is destroyed or the client is not ready. diff --git a/src/music/audio/HttpStreams.mjs b/src/music/audio/HttpStreams.mjs index 6f8677f..f16358a 100644 --- a/src/music/audio/HttpStreams.mjs +++ b/src/music/audio/HttpStreams.mjs @@ -80,7 +80,10 @@ const HttpStreams = { }); req.on("socket", (socket) => { - socket.on("error", () => {}); + if (!socket._hasRemixErrorHandler) { + socket._hasRemixErrorHandler = true; + socket.on("error", () => {}); + } }); req.on("error", reject); req.setTimeout(timeoutMs, () => { @@ -170,7 +173,10 @@ const HttpStreams = { }); req.on("socket", (socket) => { - socket.on("error", () => {}); + if (!socket._hasRemixErrorHandler) { + socket._hasRemixErrorHandler = true; + socket.on("error", () => {}); + } }); req.on("error", (err) => { diff --git a/src/services/StatusChannelManager.mjs b/src/services/StatusChannelManager.mjs index aaf8144..9d9e4f6 100644 --- a/src/services/StatusChannelManager.mjs +++ b/src/services/StatusChannelManager.mjs @@ -182,7 +182,7 @@ export class StatusChannelManager { try { await this._postMessage(payload); - logger.warn(`[StatusChannel] Incident published for ${inc.name}: ${desc}`); + logger.info(`[StatusChannel] Incident published for ${inc.name}: ${desc}`); } catch (err) { logger.warn(`[StatusChannel] Failed to post incident for ${inc.name}:`, err?.message); } @@ -394,14 +394,26 @@ export class StatusChannelManager { const probe = async () => { try { - const port = this.remix.dashboard?.port || 3000; - const res = await fetch(`http://127.0.0.1:${port}/`, { - signal: AbortSignal.timeout(4000), - }); - if (res.ok || res.status === 401 || res.status === 403 || res.status === 302) { - this.resolveIncident("dashboard"); - } else { - this.triggerIncident("dashboard", `Dashboard HTTP check returned status ${res.status}`); + const rawUrl = this.remix.config?.dashboard?.url; + 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), + }); + if (res.ok || res.status === 401 || res.status === 403 || res.status === 302) { + this.resolveIncident("dashboard"); + } else { + 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) { this.triggerIncident("dashboard", `Dashboard is unreachable (${err?.message})`);