mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fix(ui/core): add transient network retries for MessageHandler and suppress upstream socket drop errors
- Add isTransientNetworkError detection in MessageHandler for UND_ERR_SOCKET, fetch failed, and 502-504 responses - Wrap reply, replyEmbed, sendMessage, sendEmbed, and editEmbed in exponential-backoff retry loops with channel fallback - Update CommandLoader to log transient network drops as warnings instead of forwarding false-positive system error telemetry
This commit is contained in:
1 parent
36139837ba
commit
4bade0869d
2 files changed
+201
-78
No files matched your search
@@ -49,6 +49,15 @@ export class CommandLoader {
|
||||
err?.code === "COMMUNICATION_DISABLED" ||
|
||||
err?.statusCode === 403;
|
||||
};
|
||||
const isNetworkError = (err) => {
|
||||
if (!err) return false;
|
||||
const status = Number(err.statusCode ?? err.status);
|
||||
if (status === 502 || status === 503 || status === 504 || status === 520 || status === 521 || status === 522 || status === 524) return true;
|
||||
const code = err.code || err.cause?.code || err.cause?.cause?.code;
|
||||
if (code === "UND_ERR_SOCKET" || code === "ECONNRESET" || code === "ETIMEDOUT") return true;
|
||||
const str = `${err.message || ""} ${err.cause?.message || ""}`.toLowerCase();
|
||||
return str.includes("other side closed") || str.includes("fetch failed");
|
||||
};
|
||||
const sendErrorReply = (id) => {
|
||||
Promise.resolve(data.message.reply("An error occurred. Error id: `#" + id + "`"))
|
||||
.catch(err => logger.warn("[CommandHandler] Failed to send error-reply; error id #" + id + ":", err?.message));
|
||||
@@ -58,6 +67,10 @@ export class CommandLoader {
|
||||
logger.warn(`[CommandHandler] Missing permissions in channel ${data.message?.channelId ?? data.message?.channel?.id}: ${e.code ?? e.message}`);
|
||||
return;
|
||||
}
|
||||
if (isNetworkError(e)) {
|
||||
logger.warn(`[CommandHandler] Transient network or socket closure during command '${data.command?.name ?? "unknown"}': ${e.code ?? e.message}`);
|
||||
return;
|
||||
}
|
||||
const id = Utils.uid();
|
||||
logger.error("Error running command; error id #" + id, e);
|
||||
sendErrorReply(id);
|
||||
|
||||
Reference in new issue
Block a user