mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
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:
1 parent
5e39679f45
commit
0c8349f44b
5 files changed
+58
-14
No files matched your search
+19
-1
@@ -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"}`);
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -80,7 +80,10 @@ const HttpStreams = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
req.on("socket", (socket) => {
|
req.on("socket", (socket) => {
|
||||||
socket.on("error", () => {});
|
if (!socket._hasRemixErrorHandler) {
|
||||||
|
socket._hasRemixErrorHandler = true;
|
||||||
|
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) => {
|
||||||
socket.on("error", () => {});
|
if (!socket._hasRemixErrorHandler) {
|
||||||
|
socket._hasRemixErrorHandler = true;
|
||||||
|
socket.on("error", () => {});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
req.on("error", (err) => {
|
req.on("error", (err) => {
|
||||||
|
|||||||
@@ -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,14 +394,26 @@ 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;
|
||||||
signal: AbortSignal.timeout(4000),
|
const targetUrl = rawUrl || (port ? `http://127.0.0.1:${port}/` : null);
|
||||||
});
|
|
||||||
if (res.ok || res.status === 401 || res.status === 403 || res.status === 302) {
|
if (targetUrl) {
|
||||||
this.resolveIncident("dashboard");
|
const res = await fetch(targetUrl, {
|
||||||
} else {
|
signal: AbortSignal.timeout(4000),
|
||||||
this.triggerIncident("dashboard", `Dashboard HTTP check returned status ${res.status}`);
|
});
|
||||||
|
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) {
|
} catch (err) {
|
||||||
this.triggerIncident("dashboard", `Dashboard is unreachable (${err?.message})`);
|
this.triggerIncident("dashboard", `Dashboard is unreachable (${err?.message})`);
|
||||||
|
|||||||
Reference in new issue
Block a user